@Override public Map<String, List<String>> getRequestProperties() { return delegate.getRequestProperties(); }
@Override public Map<String, List<String>> getRequestProperties() { return delegate.getRequestProperties(); }
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(); }
/** * 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); } }
huc.setRequestProperty("User-agent", AbstractRipper.USER_AGENT); tries += 1; logger.debug("Request properties: " + huc.getRequestProperties().toString()); huc.connect();
logger.debug(rb.getString("request.properties") + ": " + huc.getRequestProperties()); huc.connect();
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; }
Map<String, List<String>> properties = urlConn.getRequestProperties(); if (properties != null && properties.size() > 0) {
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()) {
@Override public Map<String, List<String>> getRequestProperties() { return delegate.getRequestProperties(); }
@Override public Map<String, List<String>> getRequestProperties() { return delegate.getRequestProperties(); }
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; }
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()); } }
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); } } }
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); } } }
static void ensureRequestProperty(HttpURLConnection connection, String name, Object value) { if (!connection.getRequestProperties().containsKey(name)) { addRequestProperty(connection, name, value); } }
protected void beforeRequest(final HttpURLConnection connection) { if (DEBUG_HEADER) { for (String key : connection.getRequestProperties().keySet()) { System.out.println("Header | " + key + ": " + connection.getRequestProperty(key)); } } }
@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()); }
@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()); }
@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")); }