I try to use volley for http request. I tried a request on postman and the response headers are below :
Volley adds some extra keys and removes Content-Length
and Content-Encoding
key. I write keys and values on parseNetworkResponse
function. Response headers are below :
Content-Type : application/json; charset=utf-8 Date : Fri, 30 Jun 2017 09:05:23 GMT ETag : W/"23-E742p6pP4kakmVh3lok1ww" Server : Microsoft-IIS/8.0 Set-Cookie : ARRAffinity=16d81073e15abb17d2faba962adb6504734210ff2b9ff1ddfa770750ac7752e2;Path=/;xxx.net Vary : X-HTTP-Method-Override, Accept-Encoding,Accept-Encoding X-Android-Received-Millis : 1498813523832 X-Android-Response-Source : NETWORK 200 X-Android-Selected-Protocol : http/1.1 X-Android-Sent-Millis : 1498813523632 X-Powered-By : Express
Why does it change content? How can I get Content-Length
and Content-Encoding
?
if you are using the java.net.HttpURLConnection and the getHeaderFieldKey method, then do not forget to check the 0th element from the header according to the API reference :
Some implementations may treat the 0th header field as special, ie as the status line returned by the HTTP server. In this case, getHeaderField(0) returns the status line , but getHeaderFieldKey(0) returns null.
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.