简体   繁体   中英

How to view headers of default JDK HttpURLConnection?

There's getHeaderFields() but that returns the headers in the response HTTP message. I want the headers in the request message, not the response.

Also, what is the difference between Properties and Headers? It seems like setRequestProperty() is setting a header, but I'm not sure.

If you check the method getRequestProperties() you'll find your guess is right:

public Map<String,List<String>> getRequestProperties()

Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names . Each Map value is a unmodifiable List of Strings that represents the corresponding field values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM