org.apache.coyote.http11.filters.BufferedInputFilter Java Examples

The following examples show how to use org.apache.coyote.http11.filters.BufferedInputFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractHttp11Processor.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize standard input and output filters.
 */
protected void initializeFilters(int maxTrailerSize, Set<String> allowedTrailerHeaders,
        int maxExtensionSize, int maxSwallowSize) {
    // Create and add the identity filters.
    getInputBuffer().addFilter(new IdentityInputFilter(maxSwallowSize));
    getOutputBuffer().addFilter(new IdentityOutputFilter());

    // Create and add the chunked filters.
    getInputBuffer().addFilter( new ChunkedInputFilter(maxTrailerSize,allowedTrailerHeaders,
            maxExtensionSize, maxSwallowSize));
    getOutputBuffer().addFilter(new ChunkedOutputFilter());

    // Create and add the void filters
    getInputBuffer().addFilter(new VoidInputFilter());
    getOutputBuffer().addFilter(new VoidOutputFilter());

    // Create and add buffered input filter
    getInputBuffer().addFilter(new BufferedInputFilter());

    // Create and add the chunked filters.
    //getInputBuffer().addFilter(new GzipInputFilter());
    getOutputBuffer().addFilter(new GzipOutputFilter());

    pluggableFilterIndex = getInputBuffer().getFilters().length;
}
 
Example #2
Source File: Http11Processor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected final void sslReHandShake() throws IOException {
    if (sslSupport != null) {
        // Consume and buffer the request body, so that it does not
        // interfere with the client's handshake messages
        InputFilter[] inputFilters = inputBuffer.getFilters();
        ((BufferedInputFilter) inputFilters[Constants.BUFFERED_FILTER]).setLimit(
                maxSavePostSize);
        inputBuffer.addActiveFilter(inputFilters[Constants.BUFFERED_FILTER]);

        /*
         * Outside the try/catch because we want I/O errors during
         * renegotiation to be thrown for the caller to handle since they
         * will be fatal to the connection.
         */
        socketWrapper.doClientAuth(sslSupport);
        try {
            /*
             * Errors processing the cert chain do not affect the client
             * connection so they can be logged and swallowed here.
             */
            Object sslO = sslSupport.getPeerCertificateChain();
            if (sslO != null) {
                request.setAttribute(SSLSupport.CERTIFICATE_KEY, sslO);
            }
        } catch (IOException ioe) {
            log.warn(sm.getString("http11processor.socket.ssl"), ioe);
        }
    }
}
 
Example #3
Source File: Http11Processor.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Http11 NIO处理器.
 * 拿到连接.传递连接.处理连接.处理的关键地方.
 * 1.inputBuffer and  outputBuffer绑定在了NioSocketWrapper.
 * 2. Http11Processor持有NioSocketWrapper对象.
 * 3. NioSocketWrapper去读写数据填充到对应的两个Buffer内.
 * @param protocol
 * @param endpoint
 */
@SuppressWarnings("deprecation")
public Http11Processor(AbstractHttp11Protocol<?> protocol, AbstractEndpoint<?> endpoint) {
    super(endpoint);
    this.protocol = protocol;

    httpParser = new HttpParser(protocol.getRelaxedPathChars(),
            protocol.getRelaxedQueryChars());
    /**
     * Http11 InputBuffer  绑定到 {@link org.apache.coyote.Request}
     */
    inputBuffer = new Http11InputBuffer(request, protocol.getMaxHttpHeaderSize(),
            protocol.getRejectIllegalHeaderName(), httpParser);
    request.setInputBuffer(inputBuffer);
    /**
     * Http11 OutputBuffer  绑定到{@link org.apache.coyote.Response}
     */
    outputBuffer = new Http11OutputBuffer(response, protocol.getMaxHttpHeaderSize(),
            protocol.getSendReasonPhrase());
    response.setOutputBuffer(outputBuffer);

    // Create and add the identity filters.
    inputBuffer.addFilter(new IdentityInputFilter(protocol.getMaxSwallowSize()));
    outputBuffer.addFilter(new IdentityOutputFilter());

    // Create and add the chunked filters.
    inputBuffer.addFilter(new ChunkedInputFilter(protocol.getMaxTrailerSize(),
            protocol.getAllowedTrailerHeadersInternal(), protocol.getMaxExtensionSize(),
            protocol.getMaxSwallowSize()));
    outputBuffer.addFilter(new ChunkedOutputFilter());

    // Create and add the void filters.
    inputBuffer.addFilter(new VoidInputFilter());
    outputBuffer.addFilter(new VoidOutputFilter());

    // Create and add buffered input filter
    inputBuffer.addFilter(new BufferedInputFilter());

    // Create and add the gzip filters.
    //inputBuffer.addFilter(new GzipInputFilter());
    outputBuffer.addFilter(new GzipOutputFilter());

    pluggableFilterIndex = inputBuffer.getFilters().length;
}