java.net.HttpURLConnection.getRequestProperties()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中java.net.HttpURLConnection.getRequestProperties()方法的一些代码示例,展示了HttpURLConnection.getRequestProperties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpURLConnection.getRequestProperties()方法的具体详情如下:
包路径:java.net.HttpURLConnection
类名称:HttpURLConnection
方法名:getRequestProperties

HttpURLConnection.getRequestProperties介绍

暂无

代码示例

代码示例来源:origin: square/okhttp

@Override public Map<String, List<String>> getRequestProperties() {
 return delegate.getRequestProperties();
}

代码示例来源:origin: prestodb/presto

@Override public Map<String, List<String>> getRequestProperties() {
 return delegate.getRequestProperties();
}

代码示例来源:origin: facebook/stetho

public URLConnectionInspectorRequest(
  String requestId,
  String friendlyName,
  HttpURLConnection configuredRequest,
  @Nullable SimpleRequestEntity requestEntity,
  RequestBodyHelper requestBodyHelper) {
 super(Util.convertHeaders(configuredRequest.getRequestProperties()));
 mRequestId = requestId;
 mFriendlyName = friendlyName;
 mRequestEntity = requestEntity;
 mRequestBodyHelper = requestBodyHelper;
 mUrl = configuredRequest.getURL().toString();
 mMethod = configuredRequest.getRequestMethod();
}

代码示例来源:origin: wildfly/wildfly

/**
 * Add the appropriate Authorization header to the HttpURLConnection.
 * @param connection The HttpURLConnection to which the header will be added.
 * @param method     The HTTP method to use (GET, PUT, DELETE)
 * @param bucket     the bucket name this request is for
 * @param key        the key this request is for
 * @param pathArgs   path arguments which are part of this request
 */
private void addAuthHeader(HttpURLConnection connection, String method, String bucket, String key, Map pathArgs) {
  if(connection.getRequestProperty("Date") == null) {
    connection.setRequestProperty("Date", httpDate());
  }
  if(connection.getRequestProperty("Content-Type") == null) {
    connection.setRequestProperty("Content-Type", "");
  }
  if(this.awsAccessKeyId != null && this.awsSecretAccessKey != null) {
    String canonicalString=
        Utils.makeCanonicalString(method, bucket, key, pathArgs, connection.getRequestProperties());
    String encodedCanonical=Utils.encode(this.awsSecretAccessKey, canonicalString, false);
    connection.setRequestProperty("Authorization",
                   "AWS " + this.awsAccessKeyId + ":" + encodedCanonical);
  }
}

代码示例来源:origin: RipMeApp/ripme

huc.setRequestProperty("User-agent", AbstractRipper.USER_AGENT);
tries += 1;
logger.debug("Request properties: " + huc.getRequestProperties().toString());
huc.connect();

代码示例来源:origin: RipMeApp/ripme

logger.debug(rb.getString("request.properties") + ": " + huc.getRequestProperties());
huc.connect();

代码示例来源:origin: mttkay/signpost

public Map<String, String> getAllHeaders() {
  Map<String, List<String>> origHeaders = connection.getRequestProperties();
  Map<String, String> headers = new HashMap<String, String>(origHeaders.size());
  for (String name : origHeaders.keySet()) {
    List<String> values = origHeaders.get(name);
    if (!values.isEmpty()) {
      headers.put(name, values.get(0));
    }
  }
  return headers;
}

代码示例来源:origin: ac-pm/Inspeckage

Map<String, List<String>> properties = urlConn.getRequestProperties();
if (properties != null && properties.size() > 0) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

void authorize(HttpURLConnection c) throws IOException {
  final Map<String, List<String>> reqHdr = c.getRequestProperties();
  final SortedMap<String, String> sigHdr = new TreeMap<>();
  for (Map.Entry<String, List<String>> entry : reqHdr.entrySet()) {

代码示例来源:origin: com.squareup.okhttp/okhttp-urlconnection

@Override public Map<String, List<String>> getRequestProperties() {
 return delegate.getRequestProperties();
}

代码示例来源:origin: apiman/apiman

@Override public Map<String, List<String>> getRequestProperties() {
 return delegate.getRequestProperties();
}

代码示例来源:origin: oauth.signpost/signpost-core

public Map<String, String> getAllHeaders() {
  Map<String, List<String>> origHeaders = connection.getRequestProperties();
  Map<String, String> headers = new HashMap<String, String>(origHeaders.size());
  for (String name : origHeaders.keySet()) {
    List<String> values = origHeaders.get(name);
    if (!values.isEmpty()) {
      headers.put(name, values.get(0));
    }
  }
  return headers;
}

代码示例来源:origin: HearthStats/HearthStats.net-Uploader

private static void logRequestHeaders(HttpURLConnection connection) {
 System.out.println("-----------------------------------------------------------------");
 System.out.println("Request headers for " + connection.getURL().toExternalForm());
 for (Map.Entry<String, List<String>> entry : connection.getRequestProperties().entrySet()) {
  System.out.println("  " + entry.getKey() + "=" + entry.getValue());
 }
}

代码示例来源:origin: com.cloudbees/cloudbees-api-client-nodeps

private void dumpRequestHeaders(HttpURLConnection con) {
  if (DEBUG==null)    return;
  DEBUG.println();
  DEBUG.printf("> %s %s\n",con.getRequestMethod(),con.getURL());
  for (Entry<String, List<String>> e : con.getRequestProperties().entrySet()) {
    String header = e.getKey();
    for (String v : e.getValue()) {
      DEBUG.printf("> %s: %s\n",header,v);
    }
  }
}

代码示例来源:origin: com.cloudbees/cloudbees-api-client

private void dumpRequestHeaders(HttpURLConnection con) {
  if (DEBUG==null)    return;
  DEBUG.println();
  DEBUG.printf("> %s %s\n",con.getRequestMethod(),con.getURL());
  for (Entry<String, List<String>> e : con.getRequestProperties().entrySet()) {
    String header = e.getKey();
    for (String v : e.getValue()) {
      DEBUG.printf("> %s: %s\n",header,v);
    }
  }
}

代码示例来源:origin: hgoebl/DavidWebb

static void ensureRequestProperty(HttpURLConnection connection, String name, Object value) {
  if (!connection.getRequestProperties().containsKey(name)) {
    addRequestProperty(connection, name, value);
  }
}

代码示例来源:origin: microg/JGoogle

protected void beforeRequest(final HttpURLConnection connection) {
  if (DEBUG_HEADER) {
    for (String key : connection.getRequestProperties().keySet()) {
      System.out.println("Header | " + key + ": " + connection.getRequestProperty(key));
    }
  }
}

代码示例来源:origin: turbomanage/basic-http-client

@Override
public void logRequest(HttpURLConnection uc, Object content) throws IOException {
  log("=== HTTP Request ===");
  log(uc.getRequestMethod() + " " + uc.getURL().toString());
  if (content instanceof String) {
    log("Content: " + (String) content);
  }
  logHeaders(uc.getRequestProperties());
}

代码示例来源:origin: com.turbomanage.basic-http-client/http-client-java

@Override
public void logRequest(HttpURLConnection uc, Object content) throws IOException {
  log("=== HTTP Request ===");
  log(uc.getRequestMethod() + " " + uc.getURL().toString());
  if (content instanceof String) {
    log("Content: " + (String) content);
  }
  logHeaders(uc.getRequestProperties());
}

代码示例来源:origin: braintree/braintree_android

@Test(timeout = 1000)
public void setsDefaultHeaders() throws IOException {
  HttpClient httpClient = new HttpClient();
  HttpURLConnection connection = httpClient.init("http://example.com/");
  assertEquals(3, connection.getRequestProperties().size());
  assertEquals("braintree/core/" + BuildConfig.VERSION_NAME, connection.getRequestProperty("User-Agent"));
  assertEquals(Locale.getDefault().getLanguage(), connection.getRequestProperty("Accept-Language"));
  assertEquals("gzip", connection.getRequestProperty("Accept-Encoding"));
}

相关文章

HttpURLConnection类方法