Java Code Examples for java.net.HttpURLConnection#getRequestProperties()

The following examples show how to use java.net.HttpURLConnection#getRequestProperties() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static void logRequestForDebug(@NonNull HttpURLConnection conn, @Nullable byte[] requestBody) {
    Log.d(TAG, conn.getRequestMethod() + " : " + conn.getURL());
    Map<String, List<String>> properties = conn.getRequestProperties();
    for (Map.Entry<String, List<String>> property : properties.entrySet()) {
        Log.d(TAG, "    "
                + property.getKey() + " : " + Arrays.toString(property.getValue().toArray()));
    }
    if (requestBody != null) {
        try {
            Log.d(TAG, "== Request body ==");
            Log.d(TAG, new String(requestBody, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            // ignore
        }
    }
}
 
Example 2
private static void logRequestForDebug(@NonNull HttpURLConnection conn, @Nullable byte[] requestBody) {
    Log.d(TAG, conn.getRequestMethod() + " : " + conn.getURL());
    Map<String, List<String>> properties = conn.getRequestProperties();
    for (Map.Entry<String, List<String>> property : properties.entrySet()) {
        Log.d(TAG, "    "
                + property.getKey() + " : " + Arrays.toString(property.getValue().toArray()));
    }
    if (requestBody != null) {
        try {
            Log.d(TAG, "== Request body ==");
            Log.d(TAG, new String(requestBody, "utf-8"));
        } catch (UnsupportedEncodingException e) {
            // ignore
        }
    }
}
 
Example 3
public HttpURLConnectionExtractAdapter(final HttpURLConnection connection) {
  final Map<String,List<String>> requestProperties = connection.getRequestProperties();
  if (requestProperties == null)
    return;

  for (final Entry<String,List<String>> entry : requestProperties.entrySet()) {
    final List<String> value = entry.getValue();
    if (value != null && value.size() == 1)
      map.put(entry.getKey(), value.get(0));
  }
}
 
Example 4
private void  showRequestProperties (Worker context, HttpURLConnection conn) {
	Map<String,List<String>> reqProps = conn.getRequestProperties();
	context.debug("RequestProperties for [" + conn.getURL() + "]");
	for (String key : reqProps.keySet()) {
		String propStr = "RequestPropery[" + key + "] = {";
		for (String val : reqProps.get(key)) {
			propStr += "[" + val + "]";
		}
		context.debug(propStr + "}");
	}
}
 
Example 5
public static void  showRequestProperties (Worker context, HttpURLConnection conn) {
	Map<String,List<String>> reqProps = conn.getRequestProperties();
	context.debug("RequestProperties for [" + conn.getURL() + "]");
	for (String key : reqProps.keySet()) {
		String propStr = "RequestPropery[" + key + "] = {";
		for (String val : reqProps.get(key)) {
			propStr += "[" + val + "]";
		}
		context.debug(propStr + "}");
	}
}