Hi John,
I take it you wanted to get the name and value of all the headers returned
in the response.  You can use the getResponseHeaders() method in any
HttpMethod which will return an array of Headers.

Each header though can contain multiple values so you'd have to iterate over
the headers and the over the values for each header.  Something like:

Header[] headers = method.getResponseHeaders();
for (int i = 0; i < headers.length; i++) {
        String headerName = headers[i].getName();
        HeaderElement[] elements = headers[i].getValues();
        for (int j = 0; j < elements.length; j++) {
                HeaderElement el = elements[j];
                // At this stage you have the header and it's value.
                // See below for information on some "funky" headers
        }
}

Some headers can contain multiple values within the header value, in
particular cookie headers do this.  You can repeat the pattern above to
iterate over the parameters of the HeaderElement to get a name value pair of
each element if that's what you want.  It really depends what level of
detail you need to go to.

Why were you wanting to do this?

Adrian Sutton, Software Engineer
Ephox Corporation
www.ephox.com


-----Original Message-----
From: John Burke [mailto:[EMAIL PROTECTED]
Sent: Friday, 4 April 2003 1:17 PM
To: [EMAIL PROTECTED]
Subject: [httpclient] Parse response for NameValuePairs?


Hi, I've looked through the API docs but didn't find what I wanted.
I'm wondering if there is a method that will find and return all 
NameValuePairs
from a given response?  If not can anyone please suggest a few lines
of code?  Thanks.
John


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to