elloralabs / webutilities

Automatically exported from code.google.com/p/webutilities
0 stars 0 forks source link

YUIMinFilter wont get all Response-Data in some cases #60

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
---------------------------
Configure Min-Filter to process a Servlet-Generated response, no static file.

What is the expected output? What do you see instead?
---------------------------
I expect the YUI-Filter to minimize the complete Servlet-Response.
Instead after about 58kb, the YUI-Response ends.

What version of the product are you using? On what operating system?
---------------------------
0.0.7

Please provide any additional information below.
---------------------------
The reason is that YUIMinFilter calls wrapper.getBytes() which 
calls stream.getByteArrayOutputStream().toByteArray();
toByteArray is per definition: "Its size is the current size of this output 
stream"

So YUIMinFilter will always process just the currently filled chunk of data 
from the downstream.

Fix
---------------------------
add the line wrapper.flushBuffer() before calling getBytes()

Changed source that worked:
---------------------------
chain.doFilter(req, wrapper);

Writer out = resp.getWriter();

wrapper.flushBuffer();
Writer outWriter = out;
OutputStream nullOutputStream = null;

Original issue reported on code.google.com by brued...@gmail.com on 31 Jul 2015 at 6:57

GoogleCodeExporter commented 8 years ago
Thanks for reporting along with possible fix. I would check and apply the same.

Original comment by rr.patil...@gmail.com on 2 Aug 2015 at 7:15

GoogleCodeExporter commented 8 years ago
https://github.com/rpatil26/webutilities/commit/eed56f9a871cac41654e1b26592f927c
ceb5c297

Original comment by rr.patil...@gmail.com on 3 Aug 2015 at 4:11