You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Enrico Olivelli <eo...@gmail.com> on 2017/01/09 15:31:08 UTC

Possible bug with Transfer-Encoding: chunked on Tomcat 8.5.9

Hi, I am upgrading from Tomcat 8.0.33 to 8.5.9.
I have the following error during a POST made with Apache-HttpClient 4.3.6

I this this is the bad "POST"

FINE Jan 09, 2017 3:45:15 PM org.apache.coyote.http11.Http11InputBuffer
parseRequestLine
BUONO: Received [POST /majordodo HTTP/1.1
Transfer-Encoding: chunked
Content-Type: application/json;charset=utf-8
Host: sviluppo06-cs7.sviluppo.dna:11986
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.6 (java 1.5)
Accept-Encoding: gzip,deflate
Authorization: Basic bWFnbmV3czptYWduZXdz

10b78
]


this is the stack trace of the error:
java.io.IOException: Invalid end of line sequence (character other than CR
or LF found)
        at
org.apache.coyote.http11.filters.ChunkedInputFilter.throwIOException(ChunkedInputFilter.java:655)
        at
org.apache.coyote.http11.filters.ChunkedInputFilter.parseCRLF(ChunkedInputFilter.java:475)
        at
org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:262)
        at
org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:256)
        at org.apache.coyote.Request.doRead(Request.java:540)
        at
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:319)
        at
org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:627)
        at
org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:342)
        at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:183)


Is it a client error on 'chunked' encoding format or is there some change
on Tomcat code which processes his kind of encoding ?

I think that the client is sending a broken request, but before the upgrade
I did not get the error, is it possible ?

I'm using Nio (not Nio2) http Connector, I'm going to to try Nio2

Thank you
Enrico Olivelli

.....

Re: Possible bug with Transfer-Encoding: chunked on Tomcat 8.5.9

Posted by Mark Thomas <ma...@apache.org>.
On 10/01/2017 10:54, Enrico Olivelli wrote:
> I have found a work-around for my case.
> The original code of my servlet was like this:
> 
> ObjectMapper mapper = new ObjectMapper();   // Jackson Mapper
> mapper.readValue(request.getInputStream(), "utf-8")
> 
> I have added a buffer to hold all the request:
> byte[] content = readFully(request.getInputStream());
> mapper.readValue(content, "utf-8")
> 
> Now the error has disappeared.
> I have not checked the code of Jackson Mapper.
> Is is possible that the ChunkedInputFilter breaks in case of reading more
> times after the end of the stream ? (calling ServletInputStream#read more
> times after -1 marker)

Looking at the source code, no.

It looks as if the client is not sending the correct end chunk.

> Should I file an issue ?

Without a test case that demonstrates this, no.

> I'm really sorry but today I have not time to create a working JUnit
> testcase to demostrate the issue. I can work on it next days.

No problem.

Mark


> 
> 
> -- Enrico
> 
> 
> 
> 2017-01-09 16:31 GMT+01:00 Enrico Olivelli <eo...@gmail.com>:
> 
>> Hi, I am upgrading from Tomcat 8.0.33 to 8.5.9.
>> I have the following error during a POST made with Apache-HttpClient 4.3.6
>>
>> I this this is the bad "POST"
>>
>> FINE Jan 09, 2017 3:45:15 PM org.apache.coyote.http11.Http11InputBuffer
>> parseRequestLine
>> BUONO: Received [POST /majordodo HTTP/1.1
>> Transfer-Encoding: chunked
>> Content-Type: application/json;charset=utf-8
>> Host: sviluppo06-cs7.sviluppo.dna:11986
>> Connection: Keep-Alive
>> User-Agent: Apache-HttpClient/4.3.6 (java 1.5)
>> Accept-Encoding: gzip,deflate
>> Authorization: Basic bWFnbmV3czptYWduZXdz
>>
>> 10b78
>> ]
>>
>>
>> this is the stack trace of the error:
>> java.io.IOException: Invalid end of line sequence (character other than CR
>> or LF found)
>>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
>> throwIOException(ChunkedInputFilter.java:655)
>>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
>> parseCRLF(ChunkedInputFilter.java:475)
>>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
>> doRead(ChunkedInputFilter.java:262)
>>         at org.apache.coyote.http11.Http11InputBuffer.doRead(
>> Http11InputBuffer.java:256)
>>         at org.apache.coyote.Request.doRead(Request.java:540)
>>         at org.apache.catalina.connector.InputBuffer.realReadBytes(
>> InputBuffer.java:319)
>>         at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(
>> InputBuffer.java:627)
>>         at org.apache.catalina.connector.InputBuffer.read(InputBuffer.
>> java:342)
>>         at org.apache.catalina.connector.CoyoteInputStream.read(
>> CoyoteInputStream.java:183)
>>
>>
>> Is it a client error on 'chunked' encoding format or is there some change
>> on Tomcat code which processes his kind of encoding ?
>>
>> I think that the client is sending a broken request, but before the
>> upgrade I did not get the error, is it possible ?
>>
>> I'm using Nio (not Nio2) http Connector, I'm going to to try Nio2
>>
>> Thank you
>> Enrico Olivelli
>>
>> .....
>>
> 


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


Re: Possible bug with Transfer-Encoding: chunked on Tomcat 8.5.9

Posted by Enrico Olivelli <eo...@gmail.com>.
I have found a work-around for my case.
The original code of my servlet was like this:

ObjectMapper mapper = new ObjectMapper();   // Jackson Mapper
mapper.readValue(request.getInputStream(), "utf-8")

I have added a buffer to hold all the request:
byte[] content = readFully(request.getInputStream());
mapper.readValue(content, "utf-8")

Now the error has disappeared.
I have not checked the code of Jackson Mapper.
Is is possible that the ChunkedInputFilter breaks in case of reading more
times after the end of the stream ? (calling ServletInputStream#read more
times after -1 marker)

Should I file an issue ?
I'm really sorry but today I have not time to create a working JUnit
testcase to demostrate the issue. I can work on it next days.


-- Enrico



2017-01-09 16:31 GMT+01:00 Enrico Olivelli <eo...@gmail.com>:

> Hi, I am upgrading from Tomcat 8.0.33 to 8.5.9.
> I have the following error during a POST made with Apache-HttpClient 4.3.6
>
> I this this is the bad "POST"
>
> FINE Jan 09, 2017 3:45:15 PM org.apache.coyote.http11.Http11InputBuffer
> parseRequestLine
> BUONO: Received [POST /majordodo HTTP/1.1
> Transfer-Encoding: chunked
> Content-Type: application/json;charset=utf-8
> Host: sviluppo06-cs7.sviluppo.dna:11986
> Connection: Keep-Alive
> User-Agent: Apache-HttpClient/4.3.6 (java 1.5)
> Accept-Encoding: gzip,deflate
> Authorization: Basic bWFnbmV3czptYWduZXdz
>
> 10b78
> ]
>
>
> this is the stack trace of the error:
> java.io.IOException: Invalid end of line sequence (character other than CR
> or LF found)
>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
> throwIOException(ChunkedInputFilter.java:655)
>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
> parseCRLF(ChunkedInputFilter.java:475)
>         at org.apache.coyote.http11.filters.ChunkedInputFilter.
> doRead(ChunkedInputFilter.java:262)
>         at org.apache.coyote.http11.Http11InputBuffer.doRead(
> Http11InputBuffer.java:256)
>         at org.apache.coyote.Request.doRead(Request.java:540)
>         at org.apache.catalina.connector.InputBuffer.realReadBytes(
> InputBuffer.java:319)
>         at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(
> InputBuffer.java:627)
>         at org.apache.catalina.connector.InputBuffer.read(InputBuffer.
> java:342)
>         at org.apache.catalina.connector.CoyoteInputStream.read(
> CoyoteInputStream.java:183)
>
>
> Is it a client error on 'chunked' encoding format or is there some change
> on Tomcat code which processes his kind of encoding ?
>
> I think that the client is sending a broken request, but before the
> upgrade I did not get the error, is it possible ?
>
> I'm using Nio (not Nio2) http Connector, I'm going to to try Nio2
>
> Thank you
> Enrico Olivelli
>
> .....
>