简体   繁体   中英

How to print all the request headers which HttpURLConnection is sending?

I am using HttpURLConnection in one of my Java program to hit a HTTP URL via Java.

I know I can set the request header value something like this.

connObj.setRequestProperty("User-Agent", "curl/7.29");

But I want to print all the request headers which is generated by URLConnection. Is that possible?

How about calling getRequestProperties() which as the documentation states

Returns an unmodifiable Map of general request properties for this connection.

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