Is there a way to get the value of a specific header using the HttpResponse
object returned by the HttpClient
execute()
method in Android?
相关问题
- Angular RxJS mergeMap types
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
Please try
HttpResponse.getAllHeaders()
for printing headers and for printing cookie in Headers.Have you tried
HttpResponse.getHeaders()
method?try the below method :-
http://www.mkyong.com/java/how-to-get-http-response-header-in-java/
There are several ways to get specific headers. HttpResponse inherits from HttpMessage, which provides the following header retrieval methods:
Header getFirstHeader(String name)
Header[] getHeaders(String name)
Header getLastHeader(String name)
In your case, you probably want
getFirstHeader(String)
. Headers can contain multiple values, hence theHeader[]
array return fromgetHeaders()
; if you only expect there to be a single header,getFirstHeader(String)
should suffice.I always use this code
Initially, I do so
Next, I'm using a simple method converts in hashmap
Now I can get any value
Maybe someone can help Good luck