Issue with Chunked encoding in tomcat/tomee with a specific file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
This post was updated on .
Hi, I need some help in identifying an issue with tomcat8/tomee7.02 with chunked encoding. This issue is happening only with a specific file and the same works with other application servers that i tested. There seems to be an issue specific to tomcat with this file's headers. I tried to do a save of same file using widows paint and it works without an issue. I'm using servlet to transfer the content to client using chunked encoding. I'm attaching the sample war which can be deployed in tomcat/tomee to reproduce the issue. I wrote a sample client program using http client to reproduce the issue. Below is the usage of the same. Deploy the war in tomcat/tomee. run the following commands from zip extracted location. The sample files are present in the context root of the web application. java -jar client.jar http://tomcathost:port/content/content.do?fileName=original.jpg I'm getting HTTP transfer failed: java.io.IOException: Protocol violation: Unexpected single newline character in chunk size error I tried to save copy of the original file by opening in windows paint and i don't see the issue java -jar client.jar http://tomcathost:port/content/content.do?fileName=edited.jpg No issue with this file.. Note : both original and edited files are present in context root and the output of the client program is a jpg file whose name will be current time in millis.jpg Please help me to understand the root cause of this issue and what possibly in headers of jpg encoding is causing this issue. Note : Code compiled with jdk 8 and also transfer is successful for other files whose size is very less or huge also ChunkedEncodingIssue.zip <http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip> -- Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

Cesar Hernandez
Hi,
Can you please provide the code of your war file example, maybe a public
github repo can work. Attachments are not transferred to the mailing list.
Also, any stack trace can provide more visibility to the list too.

El mar., 5 nov. 2019 a las 3:15, mshvr (<[hidden email]>)
escribió:

> Hi,
> I need some help in identifying an issue with tomcat8/tomee7.02 with
> chunked
> encoding. This issue is happening only with a specific file and the same
> works with other application servers that i tested. There seems to be an
> issue specific to tomcat with this file's headers. I tried to do a save of
> same file using widows paint and it works without an issue. I'm using
> servlet to transfer the content to client using chunked encoding.
> I'm attaching the sample war which can be deployed in tomcat/tomee to
> reproduce the issue. I wrote a sample client program using http client to
> reproduce the issue. Below is the usage of the same.
> Deploy the war in tomcat/tomee.
> run the following commands from zip extracted location.
> The sample files are present in the context root of the web application.
>
> java -jar client.jar
> <a href="http://tomcathost:port/content/content.do?fileName=original.jpg">http://tomcathost:port/content/content.do?fileName=original.jpg
> I'm getting HTTP transfer failed: java.io.IOException: Protocol violation:
> Unexpected single newline character in chunk size error
>
> I tried to save copy of the original file by opening in windows paint and i
> don't see the issue
> java -jar client.jar
>
> http://smunagapf1qh9z7.opentext.net:18080/content/content.do?fileName=edited.jpg
>
> No issue with this file..
> Note : both original and edited files are present in context root and the
> output of the client program is a jpg file whose name will be current time
> in millis.jpg
>
> Please help me to understand the root cause of this issue and what possibly
> in headers of jpg encoding is causing this issue.
> Note : Code compiled with jdk 8 and also transfer is successful for other
> files whose size is very less or huge also ChunkedEncodingIssue.zip
> <
> http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip>
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>


--
Atentamente:
César Hernández.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

mshvr
The stack trace looks something like below. I'll share the required sources
and exact stack trace in short time:

The link for earlier attachment (binaries only without sources) :
http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip

.
.
.
... 7 common frames omitted
Caused by: java.io.IOException: Protocol violation: Unexpected single
newline character in chunk size
at
org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:273)
~[commons-httpclient-3.1.jar:na]
at
org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
~[commons-httpclient-3.1.jar:na]
at
org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
~[commons-httpclient-3.1.jar:na]
at java.io.FilterInputStream.read(FilterInputStream.java:133)
~[na:1.8.0_141]
at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
~[commons-httpclient-3.1.jar:na]
at java.io.FilterInputStream.read(FilterInputStream.java:107)
~[na:1.8.0_141]
at
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
~[commons-httpclient-3.1.jar:na]
at java.nio.file.Files.copy(Files.java:2908) ~[na:1.8.0_141]
at java.nio.file.Files.copy(Files.java:3027) ~[na:1.8.0_141]





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Chunked encoding in tomcat/tomee with a specific file

Richard Monson-Haefel
Hi!

Thanks for reporting this.  Is the exception dump from your client
communicating with TomEE?  I'm assuming that what it is, but I want to be
sure.  If exception is generated by a TomEE instance that would be a
different situation.

Richard

On Fri, Nov 8, 2019 at 5:27 AM mshvr <[hidden email]>
wrote:

> The stack trace looks something like below. I'll share the required sources
> and exact stack trace in short time:
>
> The link for earlier attachment (binaries only without sources) :
>
> http://tomee-openejb.979440.n4.nabble.com/file/t376364/ChunkedEncodingIssue.zip
>
> .
> .
> .
> ... 7 common frames omitted
> Caused by: java.io.IOException: Protocol violation: Unexpected single
> newline character in chunk size
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:273)
> ~[commons-httpclient-3.1.jar:na]
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> ~[commons-httpclient-3.1.jar:na]
> at
>
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> ~[commons-httpclient-3.1.jar:na]
> at java.io.FilterInputStream.read(FilterInputStream.java:133)
> ~[na:1.8.0_141]
> at
>
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> ~[commons-httpclient-3.1.jar:na]
> at java.io.FilterInputStream.read(FilterInputStream.java:107)
> ~[na:1.8.0_141]
> at
>
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:127)
> ~[commons-httpclient-3.1.jar:na]
> at java.nio.file.Files.copy(Files.java:2908) ~[na:1.8.0_141]
> at java.nio.file.Files.copy(Files.java:3027) ~[na:1.8.0_141]
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>


--
Richard Monson-Haefel
https://twitter.com/rmonson
https://www.linkedin.com/in/monsonhaefel/