Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2013-05-30 03:01:16 -0400
committerGreg Wilkins2013-05-30 03:01:16 -0400
commit3a46498a27e249e3674a0f7d3441362221c27034 (patch)
treecea92f12c8dfa58b93932d3343cf87290ad913a9 /jetty-servlets/src
parentd8f2350f5093e341e098ea86d3f0045dc760ab88 (diff)
downloadorg.eclipse.jetty.project-3a46498a27e249e3674a0f7d3441362221c27034.tar.gz
org.eclipse.jetty.project-3a46498a27e249e3674a0f7d3441362221c27034.tar.xz
org.eclipse.jetty.project-3a46498a27e249e3674a0f7d3441362221c27034.zip
408909 GzipFilter setting of headers when reset and/or not compressed
defer commit until aggregate buffer overflows
Diffstat (limited to 'jetty-servlets/src')
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/AbstractCompressedStream.java46
1 files changed, 31 insertions, 15 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/AbstractCompressedStream.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/AbstractCompressedStream.java
index e5ae762f19..c27a272ee1 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/AbstractCompressedStream.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/gzip/AbstractCompressedStream.java
@@ -179,7 +179,7 @@ public abstract class AbstractCompressedStream extends ServletOutputStream
if (_out == null || _bOut != null)
{
long length=_wrapper.getContentLength();
- if (length<0 && _bOut==null || length >= 0 && length < _wrapper.getMinCompressSize())
+ if (length<0 &&_bOut==null || length >= 0 && length < _wrapper.getMinCompressSize())
doNotCompress(false);
else
doCompress();
@@ -240,7 +240,7 @@ public abstract class AbstractCompressedStream extends ServletOutputStream
if (_encoding!=null)
{
- setHeader("Content-Encoding", _encoding);
+ setHeader("Content-Encoding", _encoding);
if (_response.containsHeader("Content-Encoding"))
{
addHeader("Vary",_vary);
@@ -307,27 +307,43 @@ public abstract class AbstractCompressedStream extends ServletOutputStream
throw new IOException("CLOSED");
if (_out == null)
- {
- long length=_wrapper.getContentLength();
- if (_response.isCommitted() || (length >= 0 && length < _wrapper.getMinCompressSize()))
- doNotCompress(false);
- else if (lengthToWrite > _wrapper.getMinCompressSize())
- doCompress();
+ {
+ // If this first write is larger than buffer size, then we are committing now
+ if (lengthToWrite>_wrapper.getBufferSize())
+ {
+ // if we know this is all the content and it is less than minimum, then do not compress, otherwise do compress
+ long length=_wrapper.getContentLength();
+ if (length>=0 && length<_wrapper.getMinCompressSize())
+ doNotCompress(false); // Not compressing by size, so no vary on request headers
+ else
+ doCompress();
+ }
else
+ {
+ // start aggregating writes into a buffered output stream
_out = _bOut = new ByteArrayOutputStream2(_wrapper.getBufferSize());
+ }
}
- else if (_bOut != null)
+ // else are we aggregating writes?
+ else if (_bOut !=null)
{
- long length=_wrapper.getContentLength();
- if (_response.isCommitted() || (length >= 0 && length < _wrapper.getMinCompressSize()))
- doNotCompress(false);
- else if (lengthToWrite >= (_bOut.getBuf().length - _bOut.getCount()))
- doCompress();
+ // We are aggregating into the buffered output stream.
+
+ // If this write fills the buffer, then we are committing
+ if (lengthToWrite>=(_bOut.getBuf().length - _bOut.getCount()))
+ {
+ // if we know this is all the content and it is less than minimum, then do not compress, otherwise do compress
+ long length=_wrapper.getContentLength();
+ if (length>=0 && length<_wrapper.getMinCompressSize())
+ doNotCompress(false); // Not compressing by size, so no vary on request headers
+ else
+ doCompress();
+ }
}
}
/**
- * @see org.eclipse.jetty.http.gzip.CompressedStream#createOutputStream()
+ * @see org.eclipse.jetty.servlets.gzip.CompressedStream#getOutputStream()
*/
public OutputStream getOutputStream()
{

Back to the top