You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Mark Castillo <ca...@counterpane.com> on 2003/08/20 01:34:24 UTC

Grabbing a header from the server's response

After sending a GET request to a server, how to I pick out the name/value of
a specific header from the server's response?

Thank you. 

Re: Grabbing a header from the server's response

Posted by Laura Werner <la...@lwerner.org>.
Mark Castillo wrote:

>After sending a GET request to a server, how to I pick out the name/value of
>a specific header from the server's response?
>  
>
Call the getResponseHeader(String name) method (or one of its siblings) 
on the HttpMethod you used for the request, which is probably a 
GetMethod in this case.

-- Laura



Re: Grabbing a header from the server's response

Posted by Adrian Sutton <ad...@intencha.com>.
On 20/08/2003 9:34 AM, "Mark Castillo" <ca...@counterpane.com> wrote:

> After sending a GET request to a server, how to I pick out the name/value of
> a specific header from the server's response?
> 
> Thank you. 

Take a look at the getResponseHeader and associated methods in the GetMethod
object (actually defined by the HttpMethod interface).

Regards,

Adrian Sutton.
----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com


RE: Grabbing a header from the server's response

Posted by ro...@bellsouth.net.
I do it like this, for example, to get the new URL from the location header:
	Header header = httpget.getResponseHeader("Location");
	String newuri = header.getValue();

Ross


-----
get lined up at http://www.careerfish.com

-----Original Message-----
From: Mark Castillo [mailto:castillo@counterpane.com] 
Sent: Tuesday, August 19, 2003 7:34 PM
To: 'commons-httpclient-dev@jakarta.apache.org'
Subject: Grabbing a header from the server's response

After sending a GET request to a server, how to I pick out the name/value of
a specific header from the server's response?

Thank you. 

---------------------------------------------------------------------
To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org