You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tony Thompson <To...@stone-ware.com> on 2006/09/13 02:25:38 UTC

Handling HEAD method

I am still back on the 2.0.2 version of the client (I will get up to 3
soon) but I am having an issue that I need to know how to best patch for
now and also to make sure it is not an issue in the 3.x code.  I am
using a method that does a HEAD request (derived from GetMethod).  The
RFC states that the HEAD response MUST NOT include a response body.  The
issue is, the Content-Length header is set so the HTTPClient thinks
there should be content coming.  So, it sits and waits for the server to
send content.  In the 2.0.2 client, a method was added to deal with
various responses that should not have a response body,
canResponseHaveBody().  I think to patch this up for my situation, I
will fix readResponseBody() so that it also checks if the method is HEAD
and then assumes no body allowed.  I thought about fixing this in my
derived class but, I don't really want to override all of readResponse()
just to get it to ignore HEAD responses.

If this makes sense to have in the HTTPClient code, can the 3.x code be
fixed so that it also enforces the requirement that a HEAD response will
not have a body?

Thanks
Tony
 
This message (and any associated files) is intended only for the 
use of the individual or entity to which it is addressed and may 
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient 
you are hereby notified that any dissemination, copying or 
distribution of this message, or files associated with this message, 
is strictly prohibited. If you have received this message in error, 
please notify us immediately by replying to the message and deleting 
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.

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


Re: Handling HEAD method

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2006-09-12 at 20:25 -0400, Tony Thompson wrote:
> I am still back on the 2.0.2 version of the client (I will get up to 3
> soon) but I am having an issue that I need to know how to best patch for
> now and also to make sure it is not an issue in the 3.x code.  I am
> using a method that does a HEAD request (derived from GetMethod).  The
> RFC states that the HEAD response MUST NOT include a response body. 

Question. Why are you not using HeadMethod that comes with HttpClient,
or at the very least do not derive your custom class from that method?

HeadMethod shipped with HttpClient correctly implements the requirements
of the HTTP spec with regards to HEAD request / response handling.

http://jakarta.apache.org/commons/httpclient/xref/org/apache/commons/httpclient/methods/HeadMethod.html#147

Oleg

>  The
> issue is, the Content-Length header is set so the HTTPClient thinks
> there should be content coming.  So, it sits and waits for the server to
> send content.  In the 2.0.2 client, a method was added to deal with
> various responses that should not have a response body,
> canResponseHaveBody().  I think to patch this up for my situation, I
> will fix readResponseBody() so that it also checks if the method is HEAD
> and then assumes no body allowed.  I thought about fixing this in my
> derived class but, I don't really want to override all of readResponse()
> just to get it to ignore HEAD responses.
> 
> If this makes sense to have in the HTTPClient code, can the 3.x code be
> fixed so that it also enforces the requirement that a HEAD response will
> not have a body?
> 
> Thanks
> Tony
>  
> This message (and any associated files) is intended only for the 
> use of the individual or entity to which it is addressed and may 
> contain information that is confidential, subject to copyright or
> constitutes a trade secret. If you are not the intended recipient 
> you are hereby notified that any dissemination, copying or 
> distribution of this message, or files associated with this message, 
> is strictly prohibited. If you have received this message in error, 
> please notify us immediately by replying to the message and deleting 
> it from your computer. Messages sent to and from Stoneware, Inc.
> may be monitored.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 


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