org.eclipse.jetty.http.gzip
Class GzipResponseWrapper

java.lang.Object
  extended by javax.servlet.ServletResponseWrapper
      extended by javax.servlet.http.HttpServletResponseWrapper
          extended by org.eclipse.jetty.http.gzip.GzipResponseWrapper
All Implemented Interfaces:
HttpServletResponse, ServletResponse

public class GzipResponseWrapper
extends HttpServletResponseWrapper


Field Summary
static int DEFAULT_BUFFER_SIZE
           
static int DEFAULT_MIN_GZIP_SIZE
           
 
Fields inherited from interface javax.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
 
Constructor Summary
GzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
          Instantiates a new gzip response wrapper.
 
Method Summary
 void addHeader(String name, String value)
          The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.
 void finish()
          Finish.
 void flushBuffer()
          The default behavior of this method is to call flushBuffer() on the wrapped response object.
 ServletOutputStream getOutputStream()
          The default behavior of this method is to return getOutputStream() on the wrapped response object.
 PrintWriter getWriter()
          The default behavior of this method is to return getWriter() on the wrapped response object.
protected  GzipStream newGzipStream(HttpServletRequest request, HttpServletResponse response, long contentLength, int bufferSize, int minGzipSize)
          Allows derived implementations to replace GzipStream implementation.
protected  PrintWriter newWriter(OutputStream out, String encoding)
          Allows derived implementations to replace PrintWriter implementation.
 void noGzip()
          No gzip.
 void reset()
          The default behavior of this method is to call reset() on the wrapped response object.
 void resetBuffer()
          The default behavior of this method is to call resetBuffer() on the wrapped response object.
 void sendError(int sc)
          The default behavior of this method is to call sendError(int sc) on the wrapped response object.
 void sendError(int sc, String msg)
          The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.
 void sendRedirect(String location)
          The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.
 void setBufferSize(int bufferSize)
          The default behavior of this method is to call setBufferSize(int size) on the wrapped response object.
 void setContentLength(int length)
          The default behavior of this method is to call setContentLength(int len) on the wrapped response object.
protected  void setContentLength(long length)
           
 void setContentType(String ct)
          The default behavior of this method is to call setContentType(String type) on the wrapped response object.
 void setHeader(String name, String value)
          The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.
 void setIntHeader(String name, int value)
          The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.
 void setMimeTypes(Set<String> mimeTypes)
          Sets the mime types.
 void setMinGzipSize(int minGzipSize)
          Sets the min gzip size.
 void setStatus(int sc)
          The default behavior of this method is to call setStatus(int sc) on the wrapped response object.
 void setStatus(int sc, String sm)
          The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.
 
Methods inherited from class javax.servlet.http.HttpServletResponseWrapper
addCookie, addDateHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, setDateHeader
 
Methods inherited from class javax.servlet.ServletResponseWrapper
getBufferSize, getCharacterEncoding, getContentType, getLocale, getResponse, isCommitted, setCharacterEncoding, setLocale, setResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletResponse
getBufferSize, getCharacterEncoding, getContentType, getLocale, isCommitted, setCharacterEncoding, setLocale
 

Field Detail

DEFAULT_BUFFER_SIZE

public static int DEFAULT_BUFFER_SIZE

DEFAULT_MIN_GZIP_SIZE

public static int DEFAULT_MIN_GZIP_SIZE
Constructor Detail

GzipResponseWrapper

public GzipResponseWrapper(HttpServletRequest request,
                           HttpServletResponse response)
Instantiates a new gzip response wrapper.

Parameters:
request - the request
response - the response
Method Detail

setMimeTypes

public void setMimeTypes(Set<String> mimeTypes)
Sets the mime types.

Parameters:
mimeTypes - the new mime types

setBufferSize

public void setBufferSize(int bufferSize)
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call setBufferSize(int size) on the wrapped response object.

Specified by:
setBufferSize in interface ServletResponse
Overrides:
setBufferSize in class ServletResponseWrapper
Parameters:
bufferSize - the preferred buffer size
See Also:
ServletResponseWrapper.setBufferSize(int)

setMinGzipSize

public void setMinGzipSize(int minGzipSize)
Sets the min gzip size.

Parameters:
minGzipSize - the new min gzip size

setContentType

public void setContentType(String ct)
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call setContentType(String type) on the wrapped response object.

Specified by:
setContentType in interface ServletResponse
Overrides:
setContentType in class ServletResponseWrapper
Parameters:
ct - a String specifying the MIME type of the content
See Also:
ServletResponseWrapper.setContentType(java.lang.String)

setStatus

public void setStatus(int sc,
                      String sm)
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.

Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class HttpServletResponseWrapper
Parameters:
sc - the status code
sm - the status message
See Also:
HttpServletResponseWrapper.setStatus(int, java.lang.String)

setStatus

public void setStatus(int sc)
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Specified by:
setStatus in interface HttpServletResponse
Overrides:
setStatus in class HttpServletResponseWrapper
Parameters:
sc - the status code
See Also:
HttpServletResponseWrapper.setStatus(int)

setContentLength

public void setContentLength(int length)
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call setContentLength(int len) on the wrapped response object.

Specified by:
setContentLength in interface ServletResponse
Overrides:
setContentLength in class ServletResponseWrapper
Parameters:
length - an integer specifying the length of the content being returned to the client; sets the Content-Length header
See Also:
ServletResponseWrapper.setContentLength(int)

setContentLength

protected void setContentLength(long length)

addHeader

public void addHeader(String name,
                      String value)
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.

Specified by:
addHeader in interface HttpServletResponse
Overrides:
addHeader in class HttpServletResponseWrapper
Parameters:
name - the name of the header
value - the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See Also:
HttpServletResponseWrapper.addHeader(java.lang.String, java.lang.String)

setHeader

public void setHeader(String name,
                      String value)
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.

Specified by:
setHeader in interface HttpServletResponse
Overrides:
setHeader in class HttpServletResponseWrapper
Parameters:
name - the name of the header
value - the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See Also:
HttpServletResponseWrapper.setHeader(java.lang.String, java.lang.String)

setIntHeader

public void setIntHeader(String name,
                         int value)
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.

Specified by:
setIntHeader in interface HttpServletResponse
Overrides:
setIntHeader in class HttpServletResponseWrapper
Parameters:
name - the name of the header
value - the assigned integer value
See Also:
HttpServletResponseWrapper.setIntHeader(java.lang.String, int)

flushBuffer

public void flushBuffer()
                 throws IOException
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call flushBuffer() on the wrapped response object.

Specified by:
flushBuffer in interface ServletResponse
Overrides:
flushBuffer in class ServletResponseWrapper
Throws:
IOException
See Also:
ServletResponseWrapper.flushBuffer()

reset

public void reset()
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call reset() on the wrapped response object.

Specified by:
reset in interface ServletResponse
Overrides:
reset in class ServletResponseWrapper
See Also:
ServletResponseWrapper.reset()

resetBuffer

public void resetBuffer()
Description copied from class: ServletResponseWrapper
The default behavior of this method is to call resetBuffer() on the wrapped response object.

Specified by:
resetBuffer in interface ServletResponse
Overrides:
resetBuffer in class ServletResponseWrapper
See Also:
ServletResponseWrapper.resetBuffer()

sendError

public void sendError(int sc,
                      String msg)
               throws IOException
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Parameters:
sc - the error status code
msg - the descriptive message
Throws:
IOException - If an input or output exception occurs
See Also:
HttpServletResponseWrapper.sendError(int, java.lang.String)

sendError

public void sendError(int sc)
               throws IOException
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to call sendError(int sc) on the wrapped response object.

Specified by:
sendError in interface HttpServletResponse
Overrides:
sendError in class HttpServletResponseWrapper
Parameters:
sc - the error status code
Throws:
IOException - If an input or output exception occurs
See Also:
HttpServletResponseWrapper.sendError(int)

sendRedirect

public void sendRedirect(String location)
                  throws IOException
Description copied from class: HttpServletResponseWrapper
The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.

Specified by:
sendRedirect in interface HttpServletResponse
Overrides:
sendRedirect in class HttpServletResponseWrapper
Parameters:
location - the redirect location URL
Throws:
IOException - If an input or output exception occurs
See Also:
HttpServletResponseWrapper.sendRedirect(java.lang.String)

getOutputStream

public ServletOutputStream getOutputStream()
                                    throws IOException
Description copied from class: ServletResponseWrapper
The default behavior of this method is to return getOutputStream() on the wrapped response object.

Specified by:
getOutputStream in interface ServletResponse
Overrides:
getOutputStream in class ServletResponseWrapper
Returns:
a ServletOutputStream for writing binary data
Throws:
IOException - if an input or output exception occurred
See Also:
ServletResponseWrapper.getOutputStream()

getWriter

public PrintWriter getWriter()
                      throws IOException
Description copied from class: ServletResponseWrapper
The default behavior of this method is to return getWriter() on the wrapped response object.

Specified by:
getWriter in interface ServletResponse
Overrides:
getWriter in class ServletResponseWrapper
Returns:
a PrintWriter object that can return character data to the client
Throws:
IOException - if an input or output exception occurred
See Also:
ServletResponseWrapper.getWriter()

noGzip

public void noGzip()
No gzip.


finish

public void finish()
            throws IOException
Finish.

Throws:
IOException - Signals that an I/O exception has occurred.

newGzipStream

protected GzipStream newGzipStream(HttpServletRequest request,
                                   HttpServletResponse response,
                                   long contentLength,
                                   int bufferSize,
                                   int minGzipSize)
                            throws IOException
Allows derived implementations to replace GzipStream implementation.

Parameters:
request - the request
response - the response
contentLength - the content length
bufferSize - the buffer size
minGzipSize - the min gzip size
Returns:
the gzip stream
Throws:
IOException - Signals that an I/O exception has occurred.

newWriter

protected PrintWriter newWriter(OutputStream out,
                                String encoding)
                         throws UnsupportedEncodingException
Allows derived implementations to replace PrintWriter implementation.

Parameters:
out - the out
encoding - the encoding
Returns:
the prints the writer
Throws:
UnsupportedEncodingException - the unsupported encoding exception


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.