You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "C. Benson Manica" <cb...@gmail.com> on 2013/12/04 00:55:22 UTC

Transfer-Encoding: chunked not working

Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew. I'm running a web app
with Tomcat that is returning the header "Transfer-Encoding: chunked" and
seemingly exactly one 16384-byte chunk of content that is longer than that.
Consequently the page that should be transferred is not rendered by the
user agent (Chrome in this case). AFAICT it's Tomcat that isn't sending all
the chunks properly. Why might it not be doing that? What else might be the
problem?

-- 
C. Benson Manica
cbmanica@gmail.com

Re: Transfer-Encoding: chunked not working

Posted by "C. Benson Manica" <cb...@gmail.com>.
Also, if HTTP 1.1 weren't enabled for some reason, wouldn't the default
simply be to serve the entire content, rather than the first 16384 bytes?


On Tue, Dec 3, 2013 at 4:44 PM, C. Benson Manica <cb...@gmail.com> wrote:

> <Connector port="8080" protocol="HTTP/1.1"
>                connectionTimeout="20000"
>                redirectPort="8443" />
>
> sure looks like 1.1 to me.
>
>
> On Tue, Dec 3, 2013 at 4:38 PM, Martin Gainty <mg...@hotmail.com> wrote:
>
>> chunked only works on HTTP 1.1 connections
>> display $CATALINA_HOME/conf/server.xml
>>
>> Martin--
>>
>>
>>
>>
>>
>> > Date: Tue, 3 Dec 2013 15:55:22 -0800
>> > Subject: Transfer-Encoding: chunked not working
>> > From: cbmanica@gmail.com
>> > To: users@tomcat.apache.org
>> >
>> > Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew. I'm running a web
>> app
>> > with Tomcat that is returning the header "Transfer-Encoding: chunked"
>> and
>> > seemingly exactly one 16384-byte chunk of content that is longer than
>> that.
>> > Consequently the page that should be transferred is not rendered by the
>> > user agent (Chrome in this case). AFAICT it's Tomcat that isn't sending
>> all
>> > the chunks properly. Why might it not be doing that? What else might be
>> the
>> > problem?
>> >
>> > --
>> > C. Benson Manica
>> > cbmanica@gmail.com
>>
>>
>
>
>
> --
> C. Benson Manica
> cbmanica@gmail.com
>



-- 
C. Benson Manica
cbmanica@gmail.com

Re: Transfer-Encoding: chunked not working

Posted by "C. Benson Manica" <cb...@gmail.com>.
<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

sure looks like 1.1 to me.


On Tue, Dec 3, 2013 at 4:38 PM, Martin Gainty <mg...@hotmail.com> wrote:

> chunked only works on HTTP 1.1 connections
> display $CATALINA_HOME/conf/server.xml
>
> Martin--
>
>
>
>
>
> > Date: Tue, 3 Dec 2013 15:55:22 -0800
> > Subject: Transfer-Encoding: chunked not working
> > From: cbmanica@gmail.com
> > To: users@tomcat.apache.org
> >
> > Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew. I'm running a web
> app
> > with Tomcat that is returning the header "Transfer-Encoding: chunked" and
> > seemingly exactly one 16384-byte chunk of content that is longer than
> that.
> > Consequently the page that should be transferred is not rendered by the
> > user agent (Chrome in this case). AFAICT it's Tomcat that isn't sending
> all
> > the chunks properly. Why might it not be doing that? What else might be
> the
> > problem?
> >
> > --
> > C. Benson Manica
> > cbmanica@gmail.com
>
>



-- 
C. Benson Manica
cbmanica@gmail.com

RE: Transfer-Encoding: chunked not working

Posted by Martin Gainty <mg...@hotmail.com>.
chunked only works on HTTP 1.1 connections
display $CATALINA_HOME/conf/server.xml

Martin-- 


  


> Date: Tue, 3 Dec 2013 15:55:22 -0800
> Subject: Transfer-Encoding: chunked not working
> From: cbmanica@gmail.com
> To: users@tomcat.apache.org
> 
> Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew. I'm running a web app
> with Tomcat that is returning the header "Transfer-Encoding: chunked" and
> seemingly exactly one 16384-byte chunk of content that is longer than that.
> Consequently the page that should be transferred is not rendered by the
> user agent (Chrome in this case). AFAICT it's Tomcat that isn't sending all
> the chunks properly. Why might it not be doing that? What else might be the
> problem?
> 
> -- 
> C. Benson Manica
> cbmanica@gmail.com
 		 	   		  

Re: Transfer-Encoding: chunked not working

Posted by Konstantin Kolinko <kn...@gmail.com>.
2013/12/7 Christopher Schultz <ch...@christopherschultz.net>:
> On 12/6/13, 1:07 PM, Mark Thomas wrote:
>> On 06/12/2013 17:33, C. Benson Manica wrote:
>>> I'm sure it *is* some kind of buffer boundary - 16384 is not a
>>> random number ;-) As it happens, I *did* miss some logging (my
>>> IDE made it easy to miss). I have no idea what this exception
>>> means though:
>>>
>>> SEVERE: Servlet.service() for servlet [jsp] in context with path
>>> [] threw exception [java.lang.ArrayIndexOutOfBoundsException: 0]
>>> with root cause java.lang.ArrayIndexOutOfBoundsException: 0 at
>>> org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:785)
>>>  at
>>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
>>>
>>>
>>
>>>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
>>>
>>> (rest of stack trace omitted)
>>>
>>> Presumably this is my actual problem, whatever it is?
>>
>> It means that there is a bug in your JSP. Whether that bug is in
>> code generated by Tomcat (i.e. a Tomcat bug) or an application bug
>> is TBD. You'll need to look at line 785 of the generated java file
>> for that JSP (it is in the work directory) and see.
>
> ... and the unspoken consequence of the above is that the JSP will
> abruptly stop producing output and, since the headers have already
> been sent to the client, the client sees no error at all. That would
> explain the behavior you are observing. Tomcat's chunking evidently
> does not have a problem: your JSP does instead.
>
> I wonder if your Jetty setup avoids the AOOBE due to environmental
> differences (e.g. you have data in your Jetty setup, but not in your
> Tomcat one) or perhaps your JSP triggers a bug in Tomcat which
> generates unsafe code in some situation.
>
> I'm eager to hear back from C. Benson about what's on that line of
> code... it would be nice to know if Tomcat has an obscure bug that
> needs to be fixed, or if the JSP was simply carelessly-written.

I can reproduce this behaviour with the following JSP page:
[[[
<%
for (int i=0; i<1000; i++) {
out.println(i + ": 1234567890");
}
String[] a = new String[0];
a[0] = "foo";
%>
]]]

The chunk size is 8Kb. The first 2 chunks are sent successfully, and
the exception occurs while sending the 3rd chunk.

The result is:
1). The exception is caught and properly logged into the
"localhost.${date}.log" file by
StandardWrapperValve.invoke(...):
[[[
Dec 07, 2013 0:00:00 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path []
threw exception [ (...) ]
]]]

2). Client sees 16Kb of data. There are two chunks of size 0x2000 and
terminating chunk of size 0x0.
3). The text of an error page is not rendered, as ErrorReportValve.invoke does
[[[
        if (response.isCommitted()) {
            return;
        }
]]]

4) If I add the following line at the top of the JSP page, the usual
error page 500 is displayed.
<%@page bufferSize="40000"%>

Conclusion:
This works as expected.

The ErrorReportValve cannot send the error text to the client,
because sending some data regardless of the content type of the
response would be a bad thing.

The ErrorReportValve could be changed to log the error, but the
logging part is already handled by the StandardWrapperValve, so I see
no point is such a change.

Maybe the ErrorReportValve could be changed to adjust its behaviour
depending on the content type of the response (e.g. to check if it is
text/html and append its own text/html content if that is the case).


Best regards,
Konstantin Kolinko

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


Re: Transfer-Encoding: chunked not working

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 12/6/13, 1:07 PM, Mark Thomas wrote:
> On 06/12/2013 17:33, C. Benson Manica wrote:
>> I'm sure it *is* some kind of buffer boundary - 16384 is not a 
>> random number ;-) As it happens, I *did* miss some logging (my
>> IDE made it easy to miss). I have no idea what this exception
>> means though:
>> 
>> SEVERE: Servlet.service() for servlet [jsp] in context with path
>> [] threw exception [java.lang.ArrayIndexOutOfBoundsException: 0]
>> with root cause java.lang.ArrayIndexOutOfBoundsException: 0 at 
>> org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:785)
>>  at 
>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
>>
>>
>
>> 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
>> 
>> (rest of stack trace omitted)
>> 
>> Presumably this is my actual problem, whatever it is?
> 
> It means that there is a bug in your JSP. Whether that bug is in
> code generated by Tomcat (i.e. a Tomcat bug) or an application bug
> is TBD. You'll need to look at line 785 of the generated java file
> for that JSP (it is in the work directory) and see.

... and the unspoken consequence of the above is that the JSP will
abruptly stop producing output and, since the headers have already
been sent to the client, the client sees no error at all. That would
explain the behavior you are observing. Tomcat's chunking evidently
does not have a problem: your JSP does instead.

I wonder if your Jetty setup avoids the AOOBE due to environmental
differences (e.g. you have data in your Jetty setup, but not in your
Tomcat one) or perhaps your JSP triggers a bug in Tomcat which
generates unsafe code in some situation.

I'm eager to hear back from C. Benson about what's on that line of
code... it would be nice to know if Tomcat has an obscure bug that
needs to be fixed, or if the JSP was simply carelessly-written.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSoktBAAoJEBzwKT+lPKRYMe0P/1lONDHDA8H18PRbMOj6wczm
95MX8ok7i4zEdds0DS5R9ITyNPL+8QqU7rE91dNithFglKTzAWkoCZrwtj2rbS6y
heGxN4rkshdUnBOHBo4fAk+DwfEYCZGch22TKYE4Vt4scvxUI/7VibEyOt9M49AM
GzOLzptTDxqmHDZzHczm3/NoaBfxOacoHYE12DvsA+xQSQdtadSDB8sSMLVIPnWM
wT/cNlmZ8N+xiIMzT2JrDurPtIbAelBigTsyipHLDLVq+e0Has1GR0ZQsRLcpJrs
L7oiu3pRreYEJPRtJFeGhg/RDP57BaLMbJ67O0y00xBrToR9o1UB+gUMmQGjCqoL
po2TFQHfrQZpmZ33VIebcvt8zXgx2PWShDIRR4gKzWs+XyDJlWNNnXLEzyyAJmWd
6vfAsmec/0cUXtCoo74CYkmMyNdBSRvvsSPwa0uoWlebKol12x4d90kX5eYHiSng
k5PRgbxF3t5NZkah3HVExM68E/eIHhy2Usz3H/WnWEQM/l788DCIe8QdD/ijOPME
YZ6UXm2iAIQkbM0aAS9v9yRnem1vF4GiYQlGnYBBfUsClg7hhSvu97NXegbayLJq
gMWBlnMX+uXiT2KdLsYjpa5uiLWgz0HJeMjmLrN+XVz4GTGDaSyxm3rajq/Q2oio
1qdpRPFOQ/IGYSDAkcMt
=pxi1
-----END PGP SIGNATURE-----

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


Re: Transfer-Encoding: chunked not working

Posted by Mark Thomas <ma...@apache.org>.
On 06/12/2013 17:33, C. Benson Manica wrote:
> I'm sure it *is* some kind of buffer boundary - 16384 is not a
> random number ;-) As it happens, I *did* miss some logging (my IDE
> made it easy to miss). I have no idea what this exception means
> though:
> 
> SEVERE: Servlet.service() for servlet [jsp] in context with path []
> threw exception [java.lang.ArrayIndexOutOfBoundsException: 0] with
> root cause java.lang.ArrayIndexOutOfBoundsException: 0 at
> org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:785) 
> at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
>
> 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> 
> (rest of stack trace omitted)
> 
> Presumably this is my actual problem, whatever it is?

It means that there is a bug in your JSP. Whether that bug is in code
generated by Tomcat (i.e. a Tomcat bug) or an application bug is TBD.
You'll need to look at line 785 of the generated java file for that
JSP (it is in the work directory) and see.

Mark

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


Re: Transfer-Encoding: chunked not working

Posted by "C. Benson Manica" <cb...@gmail.com>.
I'm sure it *is* some kind of buffer boundary - 16384 is not a random
number ;-) As it happens, I *did* miss some logging (my IDE made it easy to
miss). I have no idea what this exception means though:

SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw
exception [java.lang.ArrayIndexOutOfBoundsException: 0] with root cause
java.lang.ArrayIndexOutOfBoundsException: 0
at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:785)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

(rest of stack trace omitted)

Presumably this is my actual problem, whatever it is?


On Thu, Dec 5, 2013 at 10:57 PM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

>
>
>
>
> "C. Benson Manica" <cb...@gmail.com> schrieb:
> >On Thu, Dec 5, 2013 at 10:58 AM, Christopher Schultz <
> >chris@christopherschultz.net> wrote:
> >
> >> -----BEGIN PGP SIGNED MESSAGE-----
> >> Hash: SHA256
> >>
> >> C.,
> >>
> >> On 12/5/13, 12:53 PM, C. Benson Manica wrote:
> >> > The content I expect is in the neighborhood of 30K. What I get back
> >> > is
> >> >
> >> > $ curl -i http://localhost:8080/
> >> >
> >> > HTTP/1.1 200 OK^M Server: Apache-Coyote/1.1^M Set-Cookie:
> >> > JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/; HttpOnly^M
> >> > Content-Type: text/html;charset=UTF-8^M Transfer-Encoding:
> >> > chunked^M Date: Thu, 05 Dec 2013 17:47:22 GMT^M ^M
> >> >
> >> >
> >> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> >> > http://www.w3.org/TR/html4/loose.dtd"> <!-- intervening content
> >> > elided --> var s
> >>
> >> Unfortunately, curl appears to be "handling" the content for you. I
> >> think you want to look at the raw bytes coming back.
> >>
> >> I can't remember if I installed it myself or what, but you might have
> >> tcpdump on your machine already. Try this:
> >>
> >> $ sudo tcpdump -Xi lo0 src port 8080
> >>
> >
> >I got this back: (apologies if the fixed-width formatting doesn't come
> >through)
> >
> >16:34:44.954734 IP6 localhost.http-alt > localhost.61592: Flags [P.],
> >seq
> >1:9001, ack 146, win 9166, options [nop,nop,TS val 266717589 ecr
> >266717588], length 9000
> >  0x0000:  600e be82 2348 0640 0000 0000 0000 0000  `...#H.@........
> >  0x0010:  0000 0000 0000 0001 0000 0000 0000 0000  ................
> >  0x0020:  0000 0000 0000 0001 1f90 f098 239d 52e7  ............#.R.
> >  0x0030:  95db ddf9 8018 23ce 2350 0000 0101 080a  ......#.#P......
> >  0x0040:  0fe5 c995 0fe5 c994 4854 5450 2f31 2e31  ........HTTP/1.1
> >  0x0050:  2032 3030 204f 4b0d 0a53 6572 7665 723a  .200.OK..Server:
> >  0x0060:  2041 7061 6368 652d 436f 796f 7465 2f31  .Apache-Coyote/1
> >  0x0070:  2e31 0d0a 5365 742d 436f 6f6b 6965 3a20  .1..Set-Cookie:.
> >  0x0080:  4a53 4553 5349 4f4e 4944 3d38 4533 4637  JSESSIONID=8E3F7
> >  0x0090:  4631 4131 4542 4537 3733 3341 3943 3146  F1A1EBE7733A9C1F
> >  0x00a0:  3846 4142 4436 3630 3333 453b 2050 6174  8FABD66033E;.Pat
> >  0x00b0:  683d 2f3b 2048 7474 704f 6e6c 790d 0a43  h=/;.HttpOnly..C
> >  0x00c0:  6f6e 7465 6e74 2d54 7970 653a 2074 6578  ontent-Type:.tex
> >  0x00d0:  742f 6874 6d6c 3b63 6861 7273 6574 3d55  t/html;charset=U
> >  0x00e0:  5446 2d38 0d0a 5472 616e 7366 6572 2d45  TF-8..Transfer-E
> >  0x00f0:  6e63 6f64 696e 673a 2063 6875 6e6b 6564  ncoding:.chunked
> >  0x0100:  0d0a 4461 7465 3a20 4672 692c 2030 3620  ..Date:.Fri,.06.
> >
> >... much redaction ...
> >
> >  0x1df0:  426f 6f6c 6561 6e28 7363 7269 7074 2e64  Boolean(script.d
> >  0x1e00:  6f6e 6529 3b0a 2020 2020 7661 7220 730d  one);.....var.s.
> >  0x1e10:  0a30 0d0a 0d0a                           .0....
> >
> >So it looks like Tomcat is, for some reason, only sending one chunk,
> >which
> >is truncated at an arbitrary point in the output.
>
> Could this arbitrary point be an buffer boundary?  Maybe your servlet is
> causing tomcat to throw an exception an since the response is committed it
> will not be able to show a proper error page nor can it revoke the sent
> bytes.
>
> Have you looked for errors or exceptions in all log files?
>
> Regards
>  Felix
> >
> >>
> >> This will dump everything. You'll need to read a bit to see all the
> >> headers. You might also want to read-up on chunked transfer-encoding.
> >>
> >
> >Based on my rudimentary understanding, Tomcat should be sending
> >multiple
> >chunk-encoded chunks here, right?
> >
> >>
> >> > I'm not using a tool to inspect traffic, because if it becomes
> >> > that troublesome to debug a default install, I'm probably just
> >> > going to use jetty. (full disclosure: I *am* now using jetty, with
> >> > the same web application, and not running into any issues, so
> >> > whatever's going on is in Tomcat world.)
> >>
> >> Can you perhaps reduce the problem to something you could share with
> >> us? Maybe someone on the list would be willing to do all that work so
> >> that Tomcat can get fixed, assuming there is a problem.
> >>
> >
> >Possibly, but I'm not sure I'd succeed in reproducing the issue, given
> >that
> >another gentleman has already made the attempt. I'm hypothesizing at
> >this
> >point that there might be some obscure interaction between the default
> >Tomcat installation and the settings and environment that my IDE is
> >using
> >to launch Tomcat and the web application. If I get a chance, I'll try
> >to
> >put together a simple web app and post it here if I can reproduce the
> >problem. Thanks for the assistance - in the meantime, however, given
> >that
> >I've gotten this to work with Jetty, I need to get back to wrangling
> >with
> >the app itself.
> >
> >
> >>
> >> > In answer to your meta-question, brew seemed to do a reasonable job
> >> > with Tomcat, modulo this issue. I don't know that
> >> > /usr/local/Cellar/tomcat/7.0.47/libexec makes 100% sense for
> >> > $TOMCAT_HOME, but at least everything's in the same place.
> >>
> >> Good to know.
> >>
> >> - -chris
> >> -----BEGIN PGP SIGNATURE-----
> >> Version: GnuPG v1.4.15 (Darwin)
> >> Comment: GPGTools - http://gpgtools.org
> >> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> >>
> >> iQIcBAEBCAAGBQJSoMzHAAoJEBzwKT+lPKRYV+AQAL2IEEnamhh8TsEes0BChuPl
> >> uIkhrHM5i8f3OKQ6Gx4QP2aYJcjPcWg+1aGf/O7TdJsYTiWn9lQVunBfivZxtDYg
> >> ABBlu3oqiOPjv/gZWbDy6adwwpCnWG8JPV4eiLtI1K3jHiu/XDABPQH1asw0uYXV
> >> 6NsY9cLfJsMe0WKa2IJoYDabrE0LXOo7v4jLdz3TLARQ50W8RWwqhxxJrme8hSe/
> >> elCI7u2bLF93WTtWEjS6XZYDA///N54IvR1wjBDwjWAw/z5Zy+/25/RS+w3QGVDe
> >> tW51wxE0xI0Rqk44U+Kt3vi3iYp6+2CNmrT3ZnT9UzSVWmBRjM13E+tvdjiv7VLA
> >> gj+vGvRgEEtJecA3Di4+NlDsocxj865m3jEZqXDOKU1avoWDLWiIew1Ihb9qXpjU
> >> pFUZNFy+kgYnP8QBXnjW3DcJHhU43Jhb5UP1QazVDml1ZQlbX4KUwgiPOLiCr6mz
> >> VI58FUb3HZKSfyqB4xzt60TDJ7IexWq9PkjcF6wh9wkZtTMO4jV3Est7JAXcuz2w
> >> EmKp9l1/hmqKF487PHiQodIQuiK3Yis+W8cjGvubVV/vjsQ/rlFCSrt1uIbUfhoO
> >> aZ8QsBVL7UlpS3X1yqAnKPPUb84VtLteRK/DVzI13Nvxs9+KepOc68qlMZCJaXQv
> >> UNZgZmunwk6o6hiBHKe2
> >> =bQW3
> >> -----END PGP SIGNATURE-----
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
C. Benson Manica
cbmanica@gmail.com

Re: Transfer-Encoding: chunked not working

Posted by Felix Schumacher <fe...@internetallee.de>.



"C. Benson Manica" <cb...@gmail.com> schrieb:
>On Thu, Dec 5, 2013 at 10:58 AM, Christopher Schultz <
>chris@christopherschultz.net> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> C.,
>>
>> On 12/5/13, 12:53 PM, C. Benson Manica wrote:
>> > The content I expect is in the neighborhood of 30K. What I get back
>> > is
>> >
>> > $ curl -i http://localhost:8080/
>> >
>> > HTTP/1.1 200 OK^M Server: Apache-Coyote/1.1^M Set-Cookie:
>> > JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/; HttpOnly^M
>> > Content-Type: text/html;charset=UTF-8^M Transfer-Encoding:
>> > chunked^M Date: Thu, 05 Dec 2013 17:47:22 GMT^M ^M
>> >
>> >
>> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
>> > http://www.w3.org/TR/html4/loose.dtd"> <!-- intervening content
>> > elided --> var s
>>
>> Unfortunately, curl appears to be "handling" the content for you. I
>> think you want to look at the raw bytes coming back.
>>
>> I can't remember if I installed it myself or what, but you might have
>> tcpdump on your machine already. Try this:
>>
>> $ sudo tcpdump -Xi lo0 src port 8080
>>
>
>I got this back: (apologies if the fixed-width formatting doesn't come
>through)
>
>16:34:44.954734 IP6 localhost.http-alt > localhost.61592: Flags [P.],
>seq
>1:9001, ack 146, win 9166, options [nop,nop,TS val 266717589 ecr
>266717588], length 9000
>  0x0000:  600e be82 2348 0640 0000 0000 0000 0000  `...#H.@........
>  0x0010:  0000 0000 0000 0001 0000 0000 0000 0000  ................
>  0x0020:  0000 0000 0000 0001 1f90 f098 239d 52e7  ............#.R.
>  0x0030:  95db ddf9 8018 23ce 2350 0000 0101 080a  ......#.#P......
>  0x0040:  0fe5 c995 0fe5 c994 4854 5450 2f31 2e31  ........HTTP/1.1
>  0x0050:  2032 3030 204f 4b0d 0a53 6572 7665 723a  .200.OK..Server:
>  0x0060:  2041 7061 6368 652d 436f 796f 7465 2f31  .Apache-Coyote/1
>  0x0070:  2e31 0d0a 5365 742d 436f 6f6b 6965 3a20  .1..Set-Cookie:.
>  0x0080:  4a53 4553 5349 4f4e 4944 3d38 4533 4637  JSESSIONID=8E3F7
>  0x0090:  4631 4131 4542 4537 3733 3341 3943 3146  F1A1EBE7733A9C1F
>  0x00a0:  3846 4142 4436 3630 3333 453b 2050 6174  8FABD66033E;.Pat
>  0x00b0:  683d 2f3b 2048 7474 704f 6e6c 790d 0a43  h=/;.HttpOnly..C
>  0x00c0:  6f6e 7465 6e74 2d54 7970 653a 2074 6578  ontent-Type:.tex
>  0x00d0:  742f 6874 6d6c 3b63 6861 7273 6574 3d55  t/html;charset=U
>  0x00e0:  5446 2d38 0d0a 5472 616e 7366 6572 2d45  TF-8..Transfer-E
>  0x00f0:  6e63 6f64 696e 673a 2063 6875 6e6b 6564  ncoding:.chunked
>  0x0100:  0d0a 4461 7465 3a20 4672 692c 2030 3620  ..Date:.Fri,.06.
>
>... much redaction ...
>
>  0x1df0:  426f 6f6c 6561 6e28 7363 7269 7074 2e64  Boolean(script.d
>  0x1e00:  6f6e 6529 3b0a 2020 2020 7661 7220 730d  one);.....var.s.
>  0x1e10:  0a30 0d0a 0d0a                           .0....
>
>So it looks like Tomcat is, for some reason, only sending one chunk,
>which
>is truncated at an arbitrary point in the output.

Could this arbitrary point be an buffer boundary?  Maybe your servlet is causing tomcat to throw an exception an since the response is committed it will not be able to show a proper error page nor can it revoke the sent bytes.

Have you looked for errors or exceptions in all log files? 

Regards
 Felix
>
>>
>> This will dump everything. You'll need to read a bit to see all the
>> headers. You might also want to read-up on chunked transfer-encoding.
>>
>
>Based on my rudimentary understanding, Tomcat should be sending
>multiple
>chunk-encoded chunks here, right?
>
>>
>> > I'm not using a tool to inspect traffic, because if it becomes
>> > that troublesome to debug a default install, I'm probably just
>> > going to use jetty. (full disclosure: I *am* now using jetty, with
>> > the same web application, and not running into any issues, so
>> > whatever's going on is in Tomcat world.)
>>
>> Can you perhaps reduce the problem to something you could share with
>> us? Maybe someone on the list would be willing to do all that work so
>> that Tomcat can get fixed, assuming there is a problem.
>>
>
>Possibly, but I'm not sure I'd succeed in reproducing the issue, given
>that
>another gentleman has already made the attempt. I'm hypothesizing at
>this
>point that there might be some obscure interaction between the default
>Tomcat installation and the settings and environment that my IDE is
>using
>to launch Tomcat and the web application. If I get a chance, I'll try
>to
>put together a simple web app and post it here if I can reproduce the
>problem. Thanks for the assistance - in the meantime, however, given
>that
>I've gotten this to work with Jetty, I need to get back to wrangling
>with
>the app itself.
>
>
>>
>> > In answer to your meta-question, brew seemed to do a reasonable job
>> > with Tomcat, modulo this issue. I don't know that
>> > /usr/local/Cellar/tomcat/7.0.47/libexec makes 100% sense for
>> > $TOMCAT_HOME, but at least everything's in the same place.
>>
>> Good to know.
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.15 (Darwin)
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQIcBAEBCAAGBQJSoMzHAAoJEBzwKT+lPKRYV+AQAL2IEEnamhh8TsEes0BChuPl
>> uIkhrHM5i8f3OKQ6Gx4QP2aYJcjPcWg+1aGf/O7TdJsYTiWn9lQVunBfivZxtDYg
>> ABBlu3oqiOPjv/gZWbDy6adwwpCnWG8JPV4eiLtI1K3jHiu/XDABPQH1asw0uYXV
>> 6NsY9cLfJsMe0WKa2IJoYDabrE0LXOo7v4jLdz3TLARQ50W8RWwqhxxJrme8hSe/
>> elCI7u2bLF93WTtWEjS6XZYDA///N54IvR1wjBDwjWAw/z5Zy+/25/RS+w3QGVDe
>> tW51wxE0xI0Rqk44U+Kt3vi3iYp6+2CNmrT3ZnT9UzSVWmBRjM13E+tvdjiv7VLA
>> gj+vGvRgEEtJecA3Di4+NlDsocxj865m3jEZqXDOKU1avoWDLWiIew1Ihb9qXpjU
>> pFUZNFy+kgYnP8QBXnjW3DcJHhU43Jhb5UP1QazVDml1ZQlbX4KUwgiPOLiCr6mz
>> VI58FUb3HZKSfyqB4xzt60TDJ7IexWq9PkjcF6wh9wkZtTMO4jV3Est7JAXcuz2w
>> EmKp9l1/hmqKF487PHiQodIQuiK3Yis+W8cjGvubVV/vjsQ/rlFCSrt1uIbUfhoO
>> aZ8QsBVL7UlpS3X1yqAnKPPUb84VtLteRK/DVzI13Nvxs9+KepOc68qlMZCJaXQv
>> UNZgZmunwk6o6hiBHKe2
>> =bQW3
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>


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


Re: Transfer-Encoding: chunked not working

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

C.,

On 12/5/13, 8:06 PM, C. Benson Manica wrote:
>> I got this back: (apologies if the fixed-width formatting doesn't
>> come through)

It came through just fine.

>> 16:34:44.954734 IP6 localhost.http-alt > localhost.61592: Flags
>> [P.], seq 1:9001, ack 146, win 9166, options [nop,nop,TS val
>> 266717589 ecr 266717588], length 9000 0x0000:  600e be82 2348
>> 0640 0000 0000 0000 0000  `...#H.@........ 0x0010:  0000 0000
>> 0000 0001 0000 0000 0000 0000  ................ 0x0020:  0000
>> 0000 0000 0001 1f90 f098 239d 52e7  ............#.R. 0x0030:
>> 95db ddf9 8018 23ce 2350 0000 0101 080a  ......#.#P...... 0x0040:
>> 0fe5 c995 0fe5 c994 4854 5450 2f31 2e31  ........HTTP/1.1 0x0050:
>> 2032 3030 204f 4b0d 0a53 6572 7665 723a  .200.OK..Server: 0x0060:
>> 2041 7061 6368 652d 436f 796f 7465 2f31  .Apache-Coyote/1 0x0070:
>> 2e31 0d0a 5365 742d 436f 6f6b 6965 3a20  .1..Set-Cookie:. 0x0080:
>> 4a53 4553 5349 4f4e 4944 3d38 4533 4637  JSESSIONID=8E3F7 0x0090:
>> 4631 4131 4542 4537 3733 3341 3943 3146  F1A1EBE7733A9C1F 0x00a0:
>> 3846 4142 4436 3630 3333 453b 2050 6174  8FABD66033E;.Pat 0x00b0:
>> 683d 2f3b 2048 7474 704f 6e6c 790d 0a43  h=/;.HttpOnly..C 0x00c0:
>> 6f6e 7465 6e74 2d54 7970 653a 2074 6578  ontent-Type:.tex 0x00d0:
>> 742f 6874 6d6c 3b63 6861 7273 6574 3d55  t/html;charset=U 0x00e0:
>> 5446 2d38 0d0a 5472 616e 7366 6572 2d45  TF-8..Transfer-E 0x00f0:
>> 6e63 6f64 696e 673a 2063 6875 6e6b 6564  ncoding:.chunked 0x0100:
>> 0d0a 4461 7465 3a20 4672 692c 2030 3620  ..Date:.Fri,.06.
> 
>> ... much redaction ...
> 
>> 0x1df0:  426f 6f6c 6561 6e28 7363 7269 7074 2e64
>> Boolean(script.d 0x1e00:  6f6e 6529 3b0a 2020 2020 7661 7220 730d
>> one);.....var.s. 0x1e10:  0a30 0d0a 0d0a
>> .0....

Unfortunately, you redacted all of the exciting parts. The last thing
you showed before the break was still the initial headers. Can you
show me at least the end of the initial headers and preferably the
beginning of the first chunk?

>> So it looks like Tomcat is, for some reason, only sending one
>> chunk, which is truncated at an arbitrary point in the output.

One TCP/IP packet doesn't necessarily mean only a single chunk. I
can't see the first chunk-length from your tcpdump output, so it'w
tough to tell.

>> Based on my rudimentary understanding, Tomcat should be sending
>> multiple chunk-encoded chunks here, right?

That depends on the flushing behavior of the webapp and a few other
things. If there is no flush() occurring, I would expect Tomcat to
send roughly equally-sized chunks which match whatever its buffer size
is until there is no more content to return.

>> I'm hypothesizing at this point that there might be some obscure
>> interaction between the default Tomcat installation and the
>> settings and environment that my IDE is using to launch Tomcat
>> and the web application. If I get a chance, I'll try to put
>> together a simple web app and post it here if I can reproduce
>> the problem. Thanks for the assistance - in the meantime,
>> however, given that I've gotten this to work with Jetty, I need
>> to get back to wrangling with the app itself.

I understand. :(

Good luck,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSokpJAAoJEBzwKT+lPKRYw64P/3cdg516TjaA1DpJ2JlNQCob
U8EV3e5nnS0R5yskLVv+faigzzVGxSA7qOzc9dY0bGQ/yXWEhVcyJklwpzfycL7v
QMRplsluNBnxB9bBbEzR55qWqNXZl2W7sQ4PeVuK+MMrWwLvPQ+jshyoxZEtUtS8
fxSqtIgATvGIZH0SyqG9s0H87xxFyuAnbdhl9K3w2pkeba+3ie8Nl0321NQQalS2
SOV5sHnpee8ndhpLruwN7jC9mAP0e8Q8h8Q/PsoiwENHnwgO1TUCCI6XyL28bBh1
aUfN2mwKDAB82JMm1DVU/uwJVT+YeJmXI/m81HxpRf6WpstrQrSQHJIU46DLfOmK
FxzIzpcoy4efeBbexawBuMnItYwMpXAk0FhqR9yld4od+ZJzpDYo87jhZ/qni9tj
p6pMyXE4EguPoAMLH2UGf93g/38vK1e8PO4+J1t83AF7Q8GKVHxQ/hqeLyUYp5Lf
NbfcckqeH4pi+uPNqK2IYgoGxsNivBl8lsUQIyvYK4bO+rt2ePVtfCwVy9jXhC0m
+Y4z6PpPSTS+CjF/lTFDvbHKo1hOvZI/pQ1GpVjfbygXWhKZ03n5IUEFLokni9ME
dCCwuH+2WIv3boz6sq5YXP71Sk/GjoMx9I9F0j3t/esb344/qWKXCjos+yYSEP9r
/299qjhDn4m5XryAuBOO
=PdZ/
-----END PGP SIGNATURE-----

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


Re: Transfer-Encoding: chunked not working

Posted by "C. Benson Manica" <cb...@gmail.com>.
On Thu, Dec 5, 2013 at 10:58 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> C.,
>
> On 12/5/13, 12:53 PM, C. Benson Manica wrote:
> > The content I expect is in the neighborhood of 30K. What I get back
> > is
> >
> > $ curl -i http://localhost:8080/
> >
> > HTTP/1.1 200 OK^M Server: Apache-Coyote/1.1^M Set-Cookie:
> > JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/; HttpOnly^M
> > Content-Type: text/html;charset=UTF-8^M Transfer-Encoding:
> > chunked^M Date: Thu, 05 Dec 2013 17:47:22 GMT^M ^M
> >
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> > http://www.w3.org/TR/html4/loose.dtd"> <!-- intervening content
> > elided --> var s
>
> Unfortunately, curl appears to be "handling" the content for you. I
> think you want to look at the raw bytes coming back.
>
> I can't remember if I installed it myself or what, but you might have
> tcpdump on your machine already. Try this:
>
> $ sudo tcpdump -Xi lo0 src port 8080
>

I got this back: (apologies if the fixed-width formatting doesn't come
through)

16:34:44.954734 IP6 localhost.http-alt > localhost.61592: Flags [P.], seq
1:9001, ack 146, win 9166, options [nop,nop,TS val 266717589 ecr
266717588], length 9000
  0x0000:  600e be82 2348 0640 0000 0000 0000 0000  `...#H.@........
  0x0010:  0000 0000 0000 0001 0000 0000 0000 0000  ................
  0x0020:  0000 0000 0000 0001 1f90 f098 239d 52e7  ............#.R.
  0x0030:  95db ddf9 8018 23ce 2350 0000 0101 080a  ......#.#P......
  0x0040:  0fe5 c995 0fe5 c994 4854 5450 2f31 2e31  ........HTTP/1.1
  0x0050:  2032 3030 204f 4b0d 0a53 6572 7665 723a  .200.OK..Server:
  0x0060:  2041 7061 6368 652d 436f 796f 7465 2f31  .Apache-Coyote/1
  0x0070:  2e31 0d0a 5365 742d 436f 6f6b 6965 3a20  .1..Set-Cookie:.
  0x0080:  4a53 4553 5349 4f4e 4944 3d38 4533 4637  JSESSIONID=8E3F7
  0x0090:  4631 4131 4542 4537 3733 3341 3943 3146  F1A1EBE7733A9C1F
  0x00a0:  3846 4142 4436 3630 3333 453b 2050 6174  8FABD66033E;.Pat
  0x00b0:  683d 2f3b 2048 7474 704f 6e6c 790d 0a43  h=/;.HttpOnly..C
  0x00c0:  6f6e 7465 6e74 2d54 7970 653a 2074 6578  ontent-Type:.tex
  0x00d0:  742f 6874 6d6c 3b63 6861 7273 6574 3d55  t/html;charset=U
  0x00e0:  5446 2d38 0d0a 5472 616e 7366 6572 2d45  TF-8..Transfer-E
  0x00f0:  6e63 6f64 696e 673a 2063 6875 6e6b 6564  ncoding:.chunked
  0x0100:  0d0a 4461 7465 3a20 4672 692c 2030 3620  ..Date:.Fri,.06.

... much redaction ...

  0x1df0:  426f 6f6c 6561 6e28 7363 7269 7074 2e64  Boolean(script.d
  0x1e00:  6f6e 6529 3b0a 2020 2020 7661 7220 730d  one);.....var.s.
  0x1e10:  0a30 0d0a 0d0a                           .0....

So it looks like Tomcat is, for some reason, only sending one chunk, which
is truncated at an arbitrary point in the output.

>
> This will dump everything. You'll need to read a bit to see all the
> headers. You might also want to read-up on chunked transfer-encoding.
>

Based on my rudimentary understanding, Tomcat should be sending multiple
chunk-encoded chunks here, right?

>
> > I'm not using a tool to inspect traffic, because if it becomes
> > that troublesome to debug a default install, I'm probably just
> > going to use jetty. (full disclosure: I *am* now using jetty, with
> > the same web application, and not running into any issues, so
> > whatever's going on is in Tomcat world.)
>
> Can you perhaps reduce the problem to something you could share with
> us? Maybe someone on the list would be willing to do all that work so
> that Tomcat can get fixed, assuming there is a problem.
>

Possibly, but I'm not sure I'd succeed in reproducing the issue, given that
another gentleman has already made the attempt. I'm hypothesizing at this
point that there might be some obscure interaction between the default
Tomcat installation and the settings and environment that my IDE is using
to launch Tomcat and the web application. If I get a chance, I'll try to
put together a simple web app and post it here if I can reproduce the
problem. Thanks for the assistance - in the meantime, however, given that
I've gotten this to work with Jetty, I need to get back to wrangling with
the app itself.


>
> > In answer to your meta-question, brew seemed to do a reasonable job
> > with Tomcat, modulo this issue. I don't know that
> > /usr/local/Cellar/tomcat/7.0.47/libexec makes 100% sense for
> > $TOMCAT_HOME, but at least everything's in the same place.
>
> Good to know.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.15 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJSoMzHAAoJEBzwKT+lPKRYV+AQAL2IEEnamhh8TsEes0BChuPl
> uIkhrHM5i8f3OKQ6Gx4QP2aYJcjPcWg+1aGf/O7TdJsYTiWn9lQVunBfivZxtDYg
> ABBlu3oqiOPjv/gZWbDy6adwwpCnWG8JPV4eiLtI1K3jHiu/XDABPQH1asw0uYXV
> 6NsY9cLfJsMe0WKa2IJoYDabrE0LXOo7v4jLdz3TLARQ50W8RWwqhxxJrme8hSe/
> elCI7u2bLF93WTtWEjS6XZYDA///N54IvR1wjBDwjWAw/z5Zy+/25/RS+w3QGVDe
> tW51wxE0xI0Rqk44U+Kt3vi3iYp6+2CNmrT3ZnT9UzSVWmBRjM13E+tvdjiv7VLA
> gj+vGvRgEEtJecA3Di4+NlDsocxj865m3jEZqXDOKU1avoWDLWiIew1Ihb9qXpjU
> pFUZNFy+kgYnP8QBXnjW3DcJHhU43Jhb5UP1QazVDml1ZQlbX4KUwgiPOLiCr6mz
> VI58FUb3HZKSfyqB4xzt60TDJ7IexWq9PkjcF6wh9wkZtTMO4jV3Est7JAXcuz2w
> EmKp9l1/hmqKF487PHiQodIQuiK3Yis+W8cjGvubVV/vjsQ/rlFCSrt1uIbUfhoO
> aZ8QsBVL7UlpS3X1yqAnKPPUb84VtLteRK/DVzI13Nvxs9+KepOc68qlMZCJaXQv
> UNZgZmunwk6o6hiBHKe2
> =bQW3
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
C. Benson Manica
cbmanica@gmail.com

Re: Transfer-Encoding: chunked not working

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

C.,

On 12/5/13, 12:53 PM, C. Benson Manica wrote:
> The content I expect is in the neighborhood of 30K. What I get back
> is
> 
> $ curl -i http://localhost:8080/
> 
> HTTP/1.1 200 OK^M Server: Apache-Coyote/1.1^M Set-Cookie:
> JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/; HttpOnly^M 
> Content-Type: text/html;charset=UTF-8^M Transfer-Encoding:
> chunked^M Date: Thu, 05 Dec 2013 17:47:22 GMT^M ^M
> 
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " 
> http://www.w3.org/TR/html4/loose.dtd"> <!-- intervening content
> elided --> var s

Unfortunately, curl appears to be "handling" the content for you. I
think you want to look at the raw bytes coming back.

I can't remember if I installed it myself or what, but you might have
tcpdump on your machine already. Try this:

$ sudo tcpdump -Xi lo0 src port 8080

This will dump everything. You'll need to read a bit to see all the
headers. You might also want to read-up on chunked transfer-encoding.

> I'm not using a tool to inspect traffic, because if it becomes
> that troublesome to debug a default install, I'm probably just
> going to use jetty. (full disclosure: I *am* now using jetty, with
> the same web application, and not running into any issues, so
> whatever's going on is in Tomcat world.)

Can you perhaps reduce the problem to something you could share with
us? Maybe someone on the list would be willing to do all that work so
that Tomcat can get fixed, assuming there is a problem.

> In answer to your meta-question, brew seemed to do a reasonable job
> with Tomcat, modulo this issue. I don't know that
> /usr/local/Cellar/tomcat/7.0.47/libexec makes 100% sense for 
> $TOMCAT_HOME, but at least everything's in the same place.

Good to know.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSoMzHAAoJEBzwKT+lPKRYV+AQAL2IEEnamhh8TsEes0BChuPl
uIkhrHM5i8f3OKQ6Gx4QP2aYJcjPcWg+1aGf/O7TdJsYTiWn9lQVunBfivZxtDYg
ABBlu3oqiOPjv/gZWbDy6adwwpCnWG8JPV4eiLtI1K3jHiu/XDABPQH1asw0uYXV
6NsY9cLfJsMe0WKa2IJoYDabrE0LXOo7v4jLdz3TLARQ50W8RWwqhxxJrme8hSe/
elCI7u2bLF93WTtWEjS6XZYDA///N54IvR1wjBDwjWAw/z5Zy+/25/RS+w3QGVDe
tW51wxE0xI0Rqk44U+Kt3vi3iYp6+2CNmrT3ZnT9UzSVWmBRjM13E+tvdjiv7VLA
gj+vGvRgEEtJecA3Di4+NlDsocxj865m3jEZqXDOKU1avoWDLWiIew1Ihb9qXpjU
pFUZNFy+kgYnP8QBXnjW3DcJHhU43Jhb5UP1QazVDml1ZQlbX4KUwgiPOLiCr6mz
VI58FUb3HZKSfyqB4xzt60TDJ7IexWq9PkjcF6wh9wkZtTMO4jV3Est7JAXcuz2w
EmKp9l1/hmqKF487PHiQodIQuiK3Yis+W8cjGvubVV/vjsQ/rlFCSrt1uIbUfhoO
aZ8QsBVL7UlpS3X1yqAnKPPUb84VtLteRK/DVzI13Nvxs9+KepOc68qlMZCJaXQv
UNZgZmunwk6o6hiBHKe2
=bQW3
-----END PGP SIGNATURE-----

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


RE: Transfer-Encoding: chunked not working

Posted by Konstantin Preißer <kp...@apache.org>.
Hi,

> -----Original Message-----
> From: C. Benson Manica [mailto:cbmanica@gmail.com]
> Sent: Thursday, December 5, 2013 6:54 PM
> To: Tomcat Users List
> Subject: Re: Transfer-Encoding: chunked not working
> 
> The content I expect is in the neighborhood of 30K. What I get back is
> 
> $ curl -i http://localhost:8080/
> 
> HTTP/1.1 200 OK^M
> Server: Apache-Coyote/1.1^M
> Set-Cookie: JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/;
> HttpOnly^M
> Content-Type: text/html;charset=UTF-8^M
> Transfer-Encoding: chunked^M
> Date: Thu, 05 Dec 2013 17:47:22 GMT^M
> ^M
> 
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> http://www.w3.org/TR/html4/loose.dtd">
> <!-- intervening content elided -->
>     var s
> 
> i.e., it just ends 16384 bytes into the full content of the page. This
> behavior also happens when I load the page in Chrome, so it's not just some
> oddity of curl.
> 
> I'm not using a tool to inspect traffic, because if it becomes that
> troublesome to debug a default install, I'm probably just going to use
> jetty. (full disclosure: I *am* now using jetty, with the same web
> application, and not running into any issues, so whatever's going on is in
> Tomcat world.)

Can you show what exactly you are doing in your web application to generate the response?

I cannot reproduce the problem with a simple servlet that e.g. writes 30000 bytes to the response with Tomcat 7.0.47.


Regards,
Konstantin Preißer


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


Re: Transfer-Encoding: chunked not working

Posted by "C. Benson Manica" <cb...@gmail.com>.
The content I expect is in the neighborhood of 30K. What I get back is

$ curl -i http://localhost:8080/

HTTP/1.1 200 OK^M
Server: Apache-Coyote/1.1^M
Set-Cookie: JSESSIONID=6ED488F581B8D3317261ADA2AD97CC20; Path=/; HttpOnly^M
Content-Type: text/html;charset=UTF-8^M
Transfer-Encoding: chunked^M
Date: Thu, 05 Dec 2013 17:47:22 GMT^M
^M


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<!-- intervening content elided -->
    var s

i.e., it just ends 16384 bytes into the full content of the page. This
behavior also happens when I load the page in Chrome, so it's not just some
oddity of curl.

I'm not using a tool to inspect traffic, because if it becomes that
troublesome to debug a default install, I'm probably just going to use
jetty. (full disclosure: I *am* now using jetty, with the same web
application, and not running into any issues, so whatever's going on is in
Tomcat world.)

In answer to your meta-question, brew seemed to do a reasonable job with
Tomcat, modulo this issue. I don't know
that /usr/local/Cellar/tomcat/7.0.47/libexec makes 100% sense for
$TOMCAT_HOME, but at least everything's in the same place.

On Wed, Dec 4, 2013 at 9:57 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Benson,
>
> On 12/3/13, 6:55 PM, C. Benson Manica wrote:
> > Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew.
>
> [As an aside, I'm interested in your experience with
> Tomcat-via-homebrew. I use Mac OS but installed Tomcat via
> direct-download. Does brew make a giant mess of everything, or is it
> pretty good?]
>
> > I'm running a web app with Tomcat that is returning the header
> > "Transfer-Encoding: chunked" and seemingly exactly one 16384-byte
> > chunk of content that is longer than that.
>
> What do you mean by the above statement? Is the content 16384 bytes
> long or isn't it? A chunked response should include a "main" response
> which just says "chunked" and then a series of actual chunks with
> content-length headers in each one.
>
> What is the content-length header in the first chunk? How many bytes
> do you actually get in that chunk? Did you get a zero-byte final
> chunk? How did you count those bytes? How many total bytes were you
> expecting?
>
> What tool are you using to inspect the traffic?
>
> > Consequently the page that should be transferred is not rendered by
> > the user agent (Chrome in this case). AFAICT it's Tomcat that isn't
> > sending all the chunks properly. Why might it not be doing that?
> > What else might be the problem?
>
> Unless your web application is doing odd things, Tomcat is responsible
> for chunking your response. If you are using a fronting web server,
> that could complicate matters, too, but it does not sound like you are
> doing that.
>
> Can you give some more information? (See above)
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.15 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJSn20BAAoJEBzwKT+lPKRY2J0QAJYX2l1LYLhHdHSR9RWgSMwK
> WOjyNsRDV4OYUL8vSPFwWH4kktgWm4i5YkLwJUqTxkjD/XjrmGHzbaI879zgZ6Qp
> W05LBZuRhQ6YERjSiZFMb0ZN3+kzqOdLJjQ1d8dSLPSP3/leWLMYF2IP8KsIpf87
> pcdwjfshujzOy1Rjpod9fYehdgIoD0vLQyH/5vIEI9kS2Peqa7mx05axOYmoaTjP
> a/y8nWdbOPfQDkHKwN+F75CHXQIbtr/jVTh9fuVdnv2EMKvySHV4vFnrh9mvTKDD
> 6FX8+ktOl/MidJ0bU1Wzo4m9rFtDBylFsWnrHEDD3MYCGoypMtIvlOGoi2NGjb4t
> CuMEWZSHdz83wFEBnEQqrfyYCcwfUMFg247+72T/6irg7PQJwFWxOUZI6lQ5XYbF
> V6wl8Lm9MzXPAL4231PO3zOxQYE2slE5XeL03zi6QuxmxW8UUaAVYP1n05vYO7AS
> LUKBYqH7Z6odH6mkDIemAOq/AOjOZLhB6XRaoRvrZKHDRpm/LwfYtt3s0TC9lD7u
> bse0THd4amYvHjBaiV34yMx+htSM7Pqk3oqwZDouvLQo/4p0lsktQLRNgFF00oBI
> ++uhC6YQNqkua9E1s1KSsCpdFrHxhb819Sj6GCyru0iNplw5awtXDcIZ83OG4UJu
> SmNsFn4XKMtyS0YK1fCj
> =Fx81
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
C. Benson Manica
cbmanica@gmail.com

Re: Transfer-Encoding: chunked not working

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Benson,

On 12/3/13, 6:55 PM, C. Benson Manica wrote:
> Tomcat 7.0.47, OSX 10.8. Fresh install via homebrew.

[As an aside, I'm interested in your experience with
Tomcat-via-homebrew. I use Mac OS but installed Tomcat via
direct-download. Does brew make a giant mess of everything, or is it
pretty good?]

> I'm running a web app with Tomcat that is returning the header 
> "Transfer-Encoding: chunked" and seemingly exactly one 16384-byte 
> chunk of content that is longer than that.

What do you mean by the above statement? Is the content 16384 bytes
long or isn't it? A chunked response should include a "main" response
which just says "chunked" and then a series of actual chunks with
content-length headers in each one.

What is the content-length header in the first chunk? How many bytes
do you actually get in that chunk? Did you get a zero-byte final
chunk? How did you count those bytes? How many total bytes were you
expecting?

What tool are you using to inspect the traffic?

> Consequently the page that should be transferred is not rendered by
> the user agent (Chrome in this case). AFAICT it's Tomcat that isn't
> sending all the chunks properly. Why might it not be doing that?
> What else might be the problem?

Unless your web application is doing odd things, Tomcat is responsible
for chunking your response. If you are using a fronting web server,
that could complicate matters, too, but it does not sound like you are
doing that.

Can you give some more information? (See above)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSn20BAAoJEBzwKT+lPKRY2J0QAJYX2l1LYLhHdHSR9RWgSMwK
WOjyNsRDV4OYUL8vSPFwWH4kktgWm4i5YkLwJUqTxkjD/XjrmGHzbaI879zgZ6Qp
W05LBZuRhQ6YERjSiZFMb0ZN3+kzqOdLJjQ1d8dSLPSP3/leWLMYF2IP8KsIpf87
pcdwjfshujzOy1Rjpod9fYehdgIoD0vLQyH/5vIEI9kS2Peqa7mx05axOYmoaTjP
a/y8nWdbOPfQDkHKwN+F75CHXQIbtr/jVTh9fuVdnv2EMKvySHV4vFnrh9mvTKDD
6FX8+ktOl/MidJ0bU1Wzo4m9rFtDBylFsWnrHEDD3MYCGoypMtIvlOGoi2NGjb4t
CuMEWZSHdz83wFEBnEQqrfyYCcwfUMFg247+72T/6irg7PQJwFWxOUZI6lQ5XYbF
V6wl8Lm9MzXPAL4231PO3zOxQYE2slE5XeL03zi6QuxmxW8UUaAVYP1n05vYO7AS
LUKBYqH7Z6odH6mkDIemAOq/AOjOZLhB6XRaoRvrZKHDRpm/LwfYtt3s0TC9lD7u
bse0THd4amYvHjBaiV34yMx+htSM7Pqk3oqwZDouvLQo/4p0lsktQLRNgFF00oBI
++uhC6YQNqkua9E1s1KSsCpdFrHxhb819Sj6GCyru0iNplw5awtXDcIZ83OG4UJu
SmNsFn4XKMtyS0YK1fCj
=Fx81
-----END PGP SIGNATURE-----

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