FileDocCategorySizeDatePackage
BufferedInputFilter.javaAPI DocApache Tomcat 6.0.143847Fri Jul 20 04:20:30 BST 2007org.apache.coyote.http11.filters

BufferedInputFilter

public class BufferedInputFilter extends Object implements org.apache.coyote.http11.InputFilter
Input filter responsible for reading and buffering the request body, so that it does not interfere with client SSL handshake messages.

Fields Summary
private static final String
ENCODING_NAME
private static final org.apache.tomcat.util.buf.ByteChunk
ENCODING
private org.apache.tomcat.util.buf.ByteChunk
buffered
private org.apache.tomcat.util.buf.ByteChunk
tempRead
private org.apache.coyote.InputBuffer
buffer
private boolean
hasRead
Constructors Summary
Methods Summary
public intavailable()

        return buffered.getLength();
    
public intdoRead(org.apache.tomcat.util.buf.ByteChunk chunk, org.apache.coyote.Request request)
Fills the given ByteChunk with the buffered request body.

        if (hasRead || buffered.getLength() <= 0) {
            return -1;
        } else {
            chunk.setBytes(buffered.getBytes(), buffered.getStart(),
                           buffered.getLength());
            hasRead = true;
        }
        return chunk.getLength();
    
public longend()

        return 0;
    
public org.apache.tomcat.util.buf.ByteChunkgetEncodingName()

        return ENCODING;
    
public voidrecycle()

        if (buffered.getBuffer().length > 65536) {
            buffered = null;
        } else {
            buffered.recycle();
        }
        tempRead.recycle();
        hasRead = false;
        buffer = null;
    
public voidsetBuffer(org.apache.coyote.InputBuffer buffer)

        this.buffer = buffer;
    
public voidsetLimit(int limit)
Set the buffering limit. This should be reset every time the buffer is used.



    // ----------------------------------------------------- Static Initializer

     
        ENCODING.setBytes(ENCODING_NAME.getBytes(), 0, ENCODING_NAME.length());
    
        if (buffered == null) {
            buffered = new ByteChunk(4048);
            buffered.setLimit(limit);
        }
    
public voidsetRequest(org.apache.coyote.Request request)
Reads the request body and buffers it.

        // save off the Request body
        try {
            while (buffer.doRead(tempRead, request) >= 0) {
                buffered.append(tempRead);
                tempRead.recycle();
            }
        } catch(IOException iex) {
            // Ignore
        }