tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: slow servlet filter for ByteArrayOutputStream response Wrapper
Date Tue, 01 Jun 2010 17:28:28 GMT
2010/6/1 Christopher Schultz <chris@christopherschultz.net>:
> On 6/1/2010 5:41 AM, Konstantin Kolinko wrote:
>> 2010/6/1 Manny Mondeo <mannynab@yahoo.com>:
>>>          httpRes.setContentLength(content.toString().length());
>>
>> Also, the above, or simplier "content.length()", will give you the
>> length measured in characters,  but Content-Length must be the length
>> measured in bytes.  For a multi-byte charset such as UTF-8 those are
>> certainly not the same. (Unless all your characters are 7-bit).
>
> I would think that this would be the problem, except that
> charCount(utf8str) <= byteCount(utf8Str), so the worst thing that could
> happen is that the Content-Length was too /short/, and the browser would
> either read everything anyway, or ignore the extra bytes. A too-long
> Content-Type can definitely cause a browser to stall.
>

There is such thing as o.a.coyote.http11.filters.IdentityOutputFilter.
If contentLength is set it will prevent sending more than the stated
number of bytes (discarding the rest of them). Thus, the data will be
trimmed at any HTML construct, or even between bytes comprising a
single multibyte character.
That is how I read the code: someone should do a test run to be sure.

> I like this error better as the cause:
>
>> >          //PrintWriter out = httpRes.getWriter();
>> >          PrintWriter out = wrapp.getWriter();
>> Why wrapp.getWriter(); ??
>
> Certainly writing to the buffered response and never to the actual
> response will not send any data to the browser. :(

Certainly. Or the code that was posted in not the one that was run.


Best regards,
Konstantin Kolinko

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


Mime
View raw message