You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jon Wingfield <jo...@mkodo.com> on 2005/01/06 12:12:37 UTC

Re: TC Drops bytes when client uses Chunked Encoding AND specifying Content-Length at the same time.

Section 4.4 of rfc2616 (HTTP1.1 spec) has rules for message-length 
processing. Rules 2 and 3 seem most pertinent.
<extract>
2.If a Transfer-Encoding header field (section 14.41) is present and
      has any value other than "identity", then the transfer-length is
      defined by use of the "chunked" transfer-coding (section 3.6),
      unless the message is terminated by closing the connection.

3.If a Content-Length header field (section 14.13) is present, its
      decimal value in OCTETs represents both the entity-length and the
      transfer-length. The Content-Length header field MUST NOT be sent
      if these two lengths are different (i.e., if a Transfer-Encoding
      header field is present). If a message is received with both a
      Transfer-Encoding header field and a Content-Length header field,
      the latter MUST be ignored.
</extract>

Looks like a bug in both TC and the client:
TC should ignore the Content-Length as per rule 3.
The client shouldn't be sending both headers as the lengths of the 
entity and transfer are different.

Jon

Ian Huynh wrote:
> We are using TC 5.0.28 on JDK 1.4.2
> 
> We have a client who POST to TC using  header "Transfer-encoding: chunked"  and at the same time specify the "Content-Length" header
> when posting to us.
> 
> It seems that if the Content-Length is specified, TC is dropping the last few bytes..??
> This same customer claims that his code works with the Jetty Servlet (which is the old embedded servlet in JBoss 3.2.1 and earlier).
> We have done some prelim testing and confirmed that 
> 
> a) if Content-Length is NOT specified and Chunked encoding is used, TC works as specified.
> b) Jetty works either way (with or without Content-Length).
> 
> My questions are:
> 
> 1. what is the correct behavior in HTTP 1.1?  I've read through the spec but am unable to ascertain whether or not Content-Lenght should NOT be
>    used when chunked encoding is used.
> 
> 2. Is this a bug in TC? 
> 
> 
> Unfortunately, our client isn't able to modify the code to NOT include the Content-Length or NOT use Chunk encoding
> 
> Thanks in advance
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 



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