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

The following examples show how to use java.net.HttpURLConnection#getRequestProperties() . 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
Source File: ChannelServiceHttpClientForTest.java    From line-sdk-android with Apache License 2.0 6 votes vote down vote up
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
Source File: ChannelServiceHttpClient.java    From line-sdk-android with Apache License 2.0 6 votes vote down vote up
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
Source File: HttpURLConnectionExtractAdapter.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
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
Source File: HttpURLConnectionWrapper.java    From WiFiAfterConnect with Apache License 2.0 5 votes vote down vote up
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
Source File: ParsedHttpInput.java    From WiFiAfterConnect with Apache License 2.0 5 votes vote down vote up
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 + "}");
	}
}