Is there a way to get the value of a specific header using the HttpResponse object returned by the HttpClient execute() method in Android?
Is there a way to get the value of a specific header using the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.