/**
* Reads the request body and buffers it.
*/
+ @Override
public void setRequest(Request request) {
// save off the Request body
try {
/**
* Fills the given ByteChunk with the buffered request body.
*/
+ @Override
public int doRead(ByteChunk chunk, Request request) throws IOException {
if (hasRead || buffered.getLength() <= 0) {
return -1;
return chunk.getLength();
}
+ @Override
public void setBuffer(InputBuffer buffer) {
this.buffer = buffer;
}
+ @Override
public void recycle() {
if (buffered != null) {
if (buffered.getBuffer().length > 65536) {
buffer = null;
}
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
+ @Override
public long end() throws IOException {
return 0;
}
+ @Override
public int available() {
return buffered.getLength();
}
* whichever is greater. If the filter does not do request body length
* control, the returned value should be -1.
*/
+ @Override
public int doRead(ByteChunk chunk, Request req)
throws IOException {
/**
* Read the content length from the request.
*/
+ @Override
public void setRequest(Request request) {
// NOOP: Request isn't used so ignore it
}
/**
* End the current request.
*/
+ @Override
public long end()
throws IOException {
/**
* Amount of bytes still available in a buffer.
*/
+ @Override
public int available() {
return (lastValid - pos);
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(InputBuffer buffer) {
this.buffer = buffer;
}
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
remaining = 0;
pos = 0;
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
*
* @return number of bytes written by the filter
*/
+ @Override
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
* necessary reading can occur in that method, as this method is called
* after the response header processing is complete.
*/
+ @Override
public void setResponse(Response response) {
// NOOP: No need for parameters from response in this filter
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(OutputBuffer buffer) {
this.buffer = buffer;
}
* End the current request. It is acceptable to write extra bytes using
* buffer.doWrite during the execution of this method.
*/
+ @Override
public long end()
throws IOException {
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
// NOOP: Nothing to recycle
}
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
*
* @return number of bytes written by the filter
*/
+ @Override
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
if (compressionStream == null) {
* necessary reading can occur in that method, as this method is called
* after the response header processing is complete.
*/
+ @Override
public void setResponse(Response response) {
// NOOP: No need for parameters from response in this filter
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(OutputBuffer buffer) {
this.buffer = buffer;
}
* End the current request. It is acceptable to write extra bytes using
* buffer.doWrite during the execution of this method.
*/
+ @Override
public long end()
throws IOException {
if (compressionStream == null) {
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
// Set compression stream to null
compressionStream = null;
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
* whichever is greater. If the filter does not do request body length
* control, the returned value should be -1.
*/
+ @Override
public int doRead(ByteChunk chunk, Request req)
throws IOException {
/**
* Read the content length from the request.
*/
+ @Override
public void setRequest(Request request) {
contentLength = request.getContentLengthLong();
remaining = contentLength;
/**
* End the current request.
*/
+ @Override
public long end()
throws IOException {
/**
* Amount of bytes still available in a buffer.
*/
+ @Override
public int available() {
return 0;
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(InputBuffer buffer) {
this.buffer = buffer;
}
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
contentLength = -1;
remaining = 0;
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
*
* @return number of bytes written by the filter
*/
+ @Override
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
* necessary reading can occur in that method, as this method is called
* after the response header processing is complete.
*/
+ @Override
public void setResponse(Response response) {
contentLength = response.getContentLengthLong();
remaining = contentLength;
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(OutputBuffer buffer) {
this.buffer = buffer;
}
* End the current request. It is acceptable to write extra bytes using
* buffer.doWrite during the execution of this method.
*/
+ @Override
public long end()
throws IOException {
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
contentLength = -1;
remaining = 0;
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
/**
* Read bytes.
*/
+ @Override
public int doRead(ByteChunk chunk, org.apache.coyote.Request request)
throws IOException {
int writeLength = 0;
/**
* Set the content length on the request.
*/
+ @Override
public void setRequest(org.apache.coyote.Request request) {
request.setContentLength(input.getLength());
}
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
input = null;
}
/**
* Return the name of the associated encoding; here, the value is null.
*/
+ @Override
public ByteChunk getEncodingName() {
return null;
}
/**
* Set the next buffer in the filter pipeline (has no effect).
*/
+ @Override
public void setBuffer(InputBuffer buffer) {
// NOOP since this filter will be providing the request body
}
/**
* Amount of bytes still available in a buffer.
*/
+ @Override
public int available() {
return input.getLength();
}
/**
* End the current request (has no effect).
*/
+ @Override
public long end() throws IOException {
return 0;
}
*
* @return number of bytes written by the filter
*/
+ @Override
public int doRead(ByteChunk chunk, Request req)
throws IOException {
/**
* Set the associated request.
*/
+ @Override
public void setRequest(Request request) {
// NOOP: Request isn't used so ignore it
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(InputBuffer buffer) {
// NOOP: No body to read
}
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
// NOOP: Nothing to recycle
}
* Return the name of the associated encoding; Here, the value is
* "void".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
* missing bytes, which would indicate an error.
* Note: It is recommended that extra bytes be swallowed by the filter.
*/
+ @Override
public long end()
throws IOException {
return 0;
/**
* Amount of bytes still available in a buffer.
*/
+ @Override
public int available() {
return 0;
}
*
* @return number of bytes written by the filter
*/
+ @Override
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
* necessary reading can occur in that method, as this method is called
* after the response header processing is complete.
*/
+ @Override
public void setResponse(Response response) {
// NOOP: No need for parameters from response in this filter
}
/**
* Set the next buffer in the filter pipeline.
*/
+ @Override
public void setBuffer(OutputBuffer buffer) {
this.buffer = buffer;
}
/**
* Make the filter ready to process the next request.
*/
+ @Override
public void recycle() {
// NOOP: Nothing to recycle
}
* Return the name of the associated encoding; Here, the value is
* "identity".
*/
+ @Override
public ByteChunk getEncodingName() {
return ENCODING;
}
* missing bytes, which would indicate an error.
* Note: It is recommended that extra bytes be swallowed by the filter.
*/
+ @Override
public long end()
throws IOException {
return 0;