hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Surprising ProtocolException due to having already set Content-Length header
Date Mon, 25 Aug 2008 09:21:33 GMT
On Sat, 2008-08-23 at 10:56 -0400, Bill Higgins wrote:
> On Sat, Aug 23, 2008 at 5:51 AM, Oleg Kalnichevski <olegk@apache.org> wrote:
> > On Fri, 2008-08-22 at 18:01 -0400, Bill Higgins wrote:

...

> >
> > Bill,
> >
> > Well behaved proxies should handle so called hop by hop headers with
> > care and certainly must not blindly send them to the next hop. See
> > section 13.5.4
> >
> > http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
> >
> > It is strongly advised to remove hop by hop headers and let HttpClient
> > re-generate them based on the composition of the request. Sometime proxy
> > may need to downgrade from HTTP/1.1 to HTTP/1.0 or visa versa. In this
> > case, for instance, HttpClient will automatically convert chunk-coded
> > entities to content-length delimited or the other way around.
> >
> > Alternatively, just plug in a custom version of RequestContent
> > interceptor.
> >
> > Hope this helps
> >
> > Oleg
> >
> 
> Thanks for the response. It was informative, but I think there's still an issue.
> 
> RequestContent was throws an exception if either "Content-Length" or
> "Transfer-Encoding". The HTTP spec section that talks about end-to-end
> and hop-by-hop headers
> (http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1)
> enumerates eight headers as hop-by-hop headers and declares everything
> but those eight to be end-to-end headers. "Transfer-Encoding" is
> listed as one of the eight hop-by-hop headers, but "Content-Length" is
> not.
> 

That does not mean proxies should blindly copy the content of the
"Content-Length" header, at least in my opinion.


> I take your point to heart about not blindly copying over all headers
> (and I'll change my code as a result), but that's a separate issue
> from ResponseContent's behavior to throw an exception if the request
> already has a "Content-Length" header set. If the behavior of
> RequestContent is based on the HTTP spec's statements about hop-by-hop
> and end-to-end headers, then its current behavior vis-a-vis
> already-set "Content-Length" header would seem to be a bug.
> 
> Thoughts?
> 

I personally think it is critically important that the Content-Length
value is generated based on properties of the entity. An incorrectly
delimited message is one of the gravest mistakes in HTTP.  

Oleg

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


Mime
View raw message