Fields Summary |
---|
protected HttpServletResponse | origResponseOriginal response |
protected static final String | infoDescriptive information about this Response implementation. |
protected ServletOutputStream | streamThe ServletOutputStream that has been returned by
getOutputStream() , if any. |
protected PrintWriter | writerThe PrintWriter that has been returned by
getWriter() , if any. |
protected int | thresholdThe threshold number to compress |
private int | debugDebug level |
protected String | contentTypeContent type |
Methods Summary |
---|
public javax.servlet.ServletOutputStream | createOutputStream()Create and return a ServletOutputStream to write the content
associated with this Response.
if (debug > 1) {
System.out.println("createOutputStream gets called");
}
CompressionResponseStream stream = new CompressionResponseStream(origResponse);
stream.setDebugLevel(debug);
stream.setBuffer(threshold);
return stream;
|
public void | finishResponse()Finish a response.
try {
if (writer != null) {
writer.close();
} else {
if (stream != null)
stream.close();
}
} catch (IOException e) {
}
|
public void | flushBuffer()Flush the buffer and commit this response.
if (debug > 1) {
System.out.println("flush buffer @ CompressionServletResponseWrapper");
}
((CompressionResponseStream)stream).flush();
|
public javax.servlet.ServletOutputStream | getOutputStream()Return the servlet output stream associated with this Response.
if (writer != null)
throw new IllegalStateException("getWriter() has already been called for this response");
if (stream == null)
stream = createOutputStream();
if (debug > 1) {
System.out.println("stream is set to "+stream+" in getOutputStream");
}
return (stream);
|
public java.io.PrintWriter | getWriter()Return the writer associated with this Response.
if (writer != null)
return (writer);
if (stream != null)
throw new IllegalStateException("getOutputStream() has already been called for this response");
stream = createOutputStream();
if (debug > 1) {
System.out.println("stream is set to "+stream+" in getWriter");
}
//String charset = getCharsetFromContentType(contentType);
String charEnc = origResponse.getCharacterEncoding();
if (debug > 1) {
System.out.println("character encoding is " + charEnc);
}
// HttpServletResponse.getCharacterEncoding() shouldn't return null
// according the spec, so feel free to remove that "if"
if (charEnc != null) {
writer = new PrintWriter(new OutputStreamWriter(stream, charEnc));
} else {
writer = new PrintWriter(stream);
}
return (writer);
|
public void | setCompressionThreshold(int threshold)Set threshold number
if (debug > 1) {
System.out.println("setCompressionThreshold to " + threshold);
}
this.threshold = threshold;
|
public void | setContentLength(int length)
|
public void | setContentType(java.lang.String contentType)Set content type
// --------------------------------------------------------- Public Methods
if (debug > 1) {
System.out.println("setContentType to "+contentType);
}
this.contentType = contentType;
origResponse.setContentType(contentType);
|
public void | setDebugLevel(int debug)Set debug level
this.debug = debug;
|