|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.util.http.CompressionHelper
public abstract class CompressionHelper
This class provides static functionality for handling compression algorithms
controlled through the Content-Coding
header field.
Field Summary | |
---|---|
static String[] |
DEFAULT_SUPPORTED_ENCODINGS
A default set of supported encodings. |
Constructor Summary | |
---|---|
CompressionHelper()
|
Method Summary | |
---|---|
static void |
finishOutputStream(OutputStream os)
Finish writing to a possibly compressed servlet output stream. |
static boolean |
isCompressed(OutputStream os)
|
static String |
selectCompressionCoding(String acceptEncoding,
String[] supportedEncodings)
|
static void |
sendError(javax.servlet.http.HttpServletResponse resp,
OutputStream os,
int status,
String message)
Write an error response to the servlet output stream. |
static void |
sendError(javax.servlet.http.HttpServletResponse resp,
OutputStream os,
int status,
String message,
Throwable e)
Write an error response to the servlet output stream. |
static OutputStream |
setupResponseOutputStream(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Parse the Accept-Encoding header of the request and set up a possibly compressed
output stream to write to. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] DEFAULT_SUPPORTED_ENCODINGS
Constructor Detail |
---|
public CompressionHelper()
Method Detail |
---|
public static String selectCompressionCoding(String acceptEncoding, String[] supportedEncodings)
acceptEncoding
- The content of an Accept-Encoding header (see section 14.3 of RFC2616).supportedEncodings
- A list of supported encodings to choose from. This list should
not contain the identity
encoding, because
noop compression is selected through a null
encoding value.
null
, if the response
should not be compressed.public static OutputStream setupResponseOutputStream(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Accept-Encoding
header of the request and set up a possibly compressed
output stream to write to. If the output is chosen to be compressed, an appropriate
Content-Encoding
is set on the passed HTTP response.
req
- The HTTP request to examine.resp
- The HTTP response.
Accept-Encoding
header of the client. The returned stream should be finished
after writing the whole response using finishOutputStream(OutputStream)
.
IOException
- Upon errors when setting response headers or setting up streams.public static boolean isCompressed(OutputStream os)
os
- An output stream previously set up using
setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
.
public static void finishOutputStream(OutputStream os) throws IOException
os
- An OutputStream returned by setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
.
IOException
- Upon I/O errors.public static void sendError(javax.servlet.http.HttpServletResponse resp, OutputStream os, int status, String message) throws IOException
setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
has been invoked before.
resp
- The servlet response.os
- An output stream previously set up using
setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
.status
- A HTTP status, which corresponds to the given error situation.message
- An optional error message.
IOException
- Upon errors writing the response to the stream.public static void sendError(javax.servlet.http.HttpServletResponse resp, OutputStream os, int status, String message, Throwable e) throws IOException
setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
has been invoked before.
resp
- The servlet response.os
- An output stream previously set up using
setupResponseOutputStream(HttpServletRequest, HttpServletResponse)
.status
- A HTTP status, which corresponds to the given error situation.message
- An optional error message.e
- An optional exception to render.
IOException
- Upon errors writing the response to the stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |