org.apache.tomcat.util.net.AprEndpoint Java Examples

The following examples show how to use org.apache.tomcat.util.net.AprEndpoint. 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: Http11AprProcessor.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean prepareSendfile(OutputFilter[] outputFilters) {
    String fileName = (String) request.getAttribute(
            org.apache.coyote.Constants.SENDFILE_FILENAME_ATTR);
    if (fileName != null) {
        // No entity body sent here
        outputBuffer.addActiveFilter(outputFilters[Constants.VOID_FILTER]);
        contentDelimitation = true;
        sendfileData = new AprEndpoint.SendfileData();
        sendfileData.fileName = fileName;
        sendfileData.start = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_START_ATTR)).longValue();
        sendfileData.end = ((Long) request.getAttribute(
                org.apache.coyote.Constants.SENDFILE_FILE_END_ATTR)).longValue();
        return true;
    }
    return false;
}
 
Example #2
Source File: AprProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public AprProcessor(SocketWrapper<Long> wrapper,
        HttpUpgradeHandler httpUpgradeProcessor, AprEndpoint endpoint,
        int asyncWriteBufferSize) {
    super(httpUpgradeProcessor,
            new AprServletInputStream(wrapper),
            new AprServletOutputStream(wrapper, asyncWriteBufferSize, endpoint));

    Socket.timeoutSet(wrapper.getSocket().longValue(), INFINITE_TIMEOUT);
}
 
Example #3
Source File: AjpAprProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {

        super(packetSize, endpoint);

        response.setOutputBuffer(new SocketOutputBuffer());

        // Allocate input and output buffers
        inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
        inputBuffer.limit(0);
        outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
    }
 
Example #4
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected Http11AprProcessor createProcessor() {

    Http11AprProcessor processor = new Http11AprProcessor(
            proto.getMaxHttpHeaderSize(), (AprEndpoint)proto.endpoint,
            proto.getMaxTrailerSize(), proto.getAllowedTrailerHeadersAsSet(),
            proto.getMaxExtensionSize(), proto.getMaxSwallowSize());

    // 设置 adapter 对象
    processor.setAdapter(proto.adapter);
    processor.setMaxKeepAliveRequests(proto.getMaxKeepAliveRequests());
    processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
    processor.setConnectionUploadTimeout(
            proto.getConnectionUploadTimeout());
    processor.setDisableUploadTimeout(proto.getDisableUploadTimeout());
    processor.setCompressionMinSize(proto.getCompressionMinSize());
    processor.setCompression(proto.getCompression());
    processor.setNoCompressionUserAgents(proto.getNoCompressionUserAgents());
    processor.setCompressableMimeTypes(proto.getCompressableMimeTypes());
    processor.setRestrictedUserAgents(proto.getRestrictedUserAgents());
    processor.setSocketBuffer(proto.getSocketBuffer());
    processor.setMaxSavePostSize(proto.getMaxSavePostSize());
    processor.setServer(proto.getServer());
    processor.setClientCertProvider(proto.getClientCertProvider());
    processor.setMaxCookieCount(proto.getMaxCookieCount());
    register(processor);
    return processor;
}
 
Example #5
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected Processor<Long> createUpgradeProcessor(
        SocketWrapper<Long> socket,
        HttpUpgradeHandler httpUpgradeProcessor)
        throws IOException {
    return new AprProcessor(socket, httpUpgradeProcessor,
            (AprEndpoint) proto.endpoint,
            proto.getUpgradeAsyncWriteBufferSize());
}
 
Example #6
Source File: AjpAprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected AjpAprProcessor createProcessor() {
    AjpAprProcessor processor = new AjpAprProcessor(proto.packetSize, (AprEndpoint)proto.endpoint);
    processor.setAdapter(proto.adapter);
    processor.setTomcatAuthentication(proto.tomcatAuthentication);
    processor.setTomcatAuthorization(proto.getTomcatAuthorization());
    processor.setRequiredSecret(proto.requiredSecret);
    processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
    processor.setClientCertProvider(proto.getClientCertProvider());
    register(processor);
    return processor;
}
 
Example #7
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation") // Inbound/Outbound based upgrade
@Override
protected void longPoll(SocketWrapper<Long> socket,
        Processor<Long> processor) {

    if (processor.isAsync()) {
        // Async
        socket.setAsync(true);
    } else if (processor.isComet()) {
        // Comet
        if (proto.endpoint.isRunning()) {
            socket.setComet(true);
            ((AprEndpoint) proto.endpoint).getPoller().add(
                    socket.getSocket().longValue(),
                    proto.endpoint.getSoTimeout(), true, false);
        } else {
            // Process a STOP directly
            ((AprEndpoint) proto.endpoint).processSocket(
                    socket.getSocket().longValue(),
                    SocketStatus.STOP);
        }
    } else if (processor.isUpgrade()) {
        // Upgraded
        Poller p = ((AprEndpoint) proto.endpoint).getPoller();
        if (p == null) {
            // Connector has been stopped
            release(socket, processor, true, false);
        } else {
            p.add(socket.getSocket().longValue(), -1, true, false);
        }
    } else {
        // Tomcat 7 proprietary upgrade
        ((AprEndpoint) proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                processor.getUpgradeInbound().getReadTimeout(),
                true, false);
    }
}
 
Example #8
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public Http11AprProtocol() {
    endpoint = new AprEndpoint();
    cHandler = new Http11ConnectionHandler(this);
    ((AprEndpoint) endpoint).setHandler(cHandler);
    setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
    setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
}
 
Example #9
Source File: AjpAprProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {

        super(packetSize, endpoint);

        response.setOutputBuffer(new SocketOutputBuffer());

        // Allocate input and output buffers
        inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
        inputBuffer.limit(0);
        outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
    }
 
Example #10
Source File: AjpAprProcessor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
@SuppressWarnings("incomplete-switch") // Other cases are handled by action()
protected void actionInternal(ActionCode actionCode, Object param) {

    switch (actionCode) {
    case ASYNC_COMPLETE: {
        if (asyncStateMachine.asyncComplete()) {
            ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                    SocketStatus.OPEN_READ);
        }
        break;
    }
    case ASYNC_SETTIMEOUT: {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        socketWrapper.setTimeout(timeout);
        break;
    }
    case ASYNC_DISPATCH: {
        if (asyncStateMachine.asyncDispatch()) {
            ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                    SocketStatus.OPEN_READ);
        }
        break;
    }
    }
}
 
Example #11
Source File: AjpAprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public AjpAprProtocol() {
    endpoint = new AprEndpoint();
    cHandler = new AjpConnectionHandler(this);
    ((AprEndpoint) endpoint).setHandler(cHandler);
    setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
    setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
    setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
    // AJP does not use Send File
    ((AprEndpoint) endpoint).setUseSendfile(false);
}
 
Example #12
Source File: AjpAprProcessor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Send an action to the connector.
 *
 * @param actionCode Type of the action
 * @param param Action parameter
 */
@Override
@SuppressWarnings("incomplete-switch") // Other cases are handled by action()
protected void actionInternal(ActionCode actionCode, Object param) {

    switch (actionCode) {
    case ASYNC_COMPLETE: {
        if (asyncStateMachine.asyncComplete()) {
            ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                    SocketStatus.OPEN_READ);
        }
        break;
    }
    case ASYNC_SETTIMEOUT: {
        if (param == null) return;
        long timeout = ((Long)param).longValue();
        socketWrapper.setTimeout(timeout);
        break;
    }
    case ASYNC_DISPATCH: {
        if (asyncStateMachine.asyncDispatch()) {
            ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper,
                    SocketStatus.OPEN_READ);
        }
        break;
    }
    }
}
 
Example #13
Source File: AjpAprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(),
                true, false);
    }
}
 
Example #14
Source File: AjpAprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the handler once the processor is no longer
 * required.
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(),
                true, false);
    }
}
 
Example #15
Source File: Http11AprProtocol.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public Http11AprProtocol() {
    super(new AprEndpoint());
}
 
Example #16
Source File: Http11AprProcessor.java    From Tomcat7.0.67 with Apache License 2.0 3 votes vote down vote up
public Http11AprProcessor(int headerBufferSize, AprEndpoint endpoint, int maxTrailerSize,
        Set<String> allowedTrailerHeaders, int maxExtensionSize, int maxSwallowSize) {

    super(endpoint);

    inputBuffer = new InternalAprInputBuffer(request, headerBufferSize);
    request.setInputBuffer(inputBuffer);

    outputBuffer = new InternalAprOutputBuffer(response, headerBufferSize);
    response.setOutputBuffer(outputBuffer);

    initializeFilters(maxTrailerSize, allowedTrailerHeaders, maxExtensionSize, maxSwallowSize);
}
 
Example #17
Source File: Http11AprProcessor.java    From tomcatsrc with Apache License 2.0 3 votes vote down vote up
public Http11AprProcessor(int headerBufferSize, AprEndpoint endpoint, int maxTrailerSize,
        Set<String> allowedTrailerHeaders, int maxExtensionSize, int maxSwallowSize) {

    super(endpoint);

    inputBuffer = new InternalAprInputBuffer(request, headerBufferSize);
    request.setInputBuffer(inputBuffer);

    outputBuffer = new InternalAprOutputBuffer(response, headerBufferSize);
    response.setOutputBuffer(outputBuffer);

    initializeFilters(maxTrailerSize, allowedTrailerHeaders, maxExtensionSize, maxSwallowSize);
}
 
Example #18
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL certificate chain file.
 */
public String getSSLCertificateChainFile() { return ((AprEndpoint)endpoint).getSSLCertificateChainFile(); }
 
Example #19
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL certificate key file.
 */
public String getSSLCertificateKeyFile() { return ((AprEndpoint)endpoint).getSSLCertificateKeyFile(); }
 
Example #20
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * SSL certificate chain file.
 */
public String getSSLCertificateChainFile() { return ((AprEndpoint)endpoint).getSSLCertificateChainFile(); }
 
Example #21
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * SSL CA certificate file.
 */
public String getSSLCACertificateFile() { return ((AprEndpoint)endpoint).getSSLCACertificateFile(); }
 
Example #22
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL honor cipher order.
 *
 * Set to <code>true</code> to enforce the <i>server's</i> cipher order
 * instead of the default which is to allow the client to choose a
 * preferred cipher.
 */
public boolean getSSLHonorCipherOrder() { return ((AprEndpoint)endpoint).getSSLHonorCipherOrder(); }
 
Example #23
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL cipher suite.
 */
public String getSSLCipherSuite() { return ((AprEndpoint)endpoint).getSSLCipherSuite(); }
 
Example #24
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * SSL verify depth.
 */
public int getSSLVerifyDepth() { return ((AprEndpoint)endpoint).getSSLVerifyDepth(); }
 
Example #25
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL CA certificate path.
 */
public String getSSLCACertificatePath() { return ((AprEndpoint)endpoint).getSSLCACertificatePath(); }
 
Example #26
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL CA revocation path.
 */
public String getSSLCARevocationPath() { return ((AprEndpoint)endpoint).getSSLCARevocationPath(); }
 
Example #27
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL verify client.
 */
public String getSSLVerifyClient() { return ((AprEndpoint)endpoint).getSSLVerifyClient(); }
 
Example #28
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL password (if a cert is encrypted, and no password has been provided, a callback
 * will ask for a password).
 */
public String getSSLPassword() { return ((AprEndpoint)endpoint).getSSLPassword(); }
 
Example #29
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL protocol.
 */
public String getSSLProtocol() { return ((AprEndpoint)endpoint).getSSLProtocol(); }
 
Example #30
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * SSL CA certificate file.
 */
public String getSSLCACertificateFile() { return ((AprEndpoint)endpoint).getSSLCACertificateFile(); }