On August 30, 2019 8:34:02 PM UTC, Dave Thorn <da...@fysh.org.INVALID> wrote: >I am reading a ~900K XML response from a Tomcat 7.0.76 server, using >Spring RestTemplate and very very intermittently I'm getting a >MalformedChunkCodingException.[1] > >"Unexpected content at the end of chunk". > >I enabled httpclient 'wire' debugging in my client and left it running >all day and I finally got a bite: > >[many things] >DEBUG org.apache.http.wire - << "datadatadata" >DEBUG org.apache.http.wire - << "[\r][\n]" >DEBUG org.apache.http.wire - << "1AB8[\r][\n]" >DEBUG org.apache.http.wire - << "datadatadata" >DEBUG org.apache.http.wire - << "[\r][\n]" >DEBUG org.apache.http.wire - << "B50[\r][\n]" >DEBUG org.apache.http.wire - << "datadatadata" >DEBUG org.apache.http.wire - << "3FC0[\r][\n]" >[exception] > >That looks, to me, like the stream is missing the [\r][\n] between the >B50 chunk and the 3FC0 count. > >I'm not clear on where the responsibilities lie in producing that >chunked output - Spring in my webapp, or Tomcat as my container? > >Thanks for any guidance you can provide.
I suspect Tomcat is doing the chunking but I'd recommend checking with the Spring folks to confirm that. I'd also recommend repeating your test with Wireshark to confirm that the server doesn't send it and that you aren't seeing a client side bug. I took a quick look at Tomcat's ChunkedOutputFilter and I don't see any obvious way the \r\n could be skipped but a strange edge case isn't impossible. Mark > > >[1] >Caused by: org.apache.http.MalformedChunkCodingException: Unexpected >content at the end of chunk > at >org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:259) > at >org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:227) > at >org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:186) > at >org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137) > at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) > at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) > at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) > at java.io.InputStreamReader.read(InputStreamReader.java:184) > at java.io.Reader.read(Reader.java:140) > at >org.springframework.util.StreamUtils.copyToString(StreamUtils.java:74) > at >org.springframework.http.converter.StringHttpMessageConverter.readInternal(StringHttpMessageConverter.java:85) > at >org.springframework.http.converter.StringHttpMessageConverter.readInternal(StringHttpMessageConverter.java:40) > at >org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153) > at >org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:103) > at >org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:724) > at >org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:709) > at >org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:527) --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org