org.apache.coyote.Processor Java Examples

The following examples show how to use org.apache.coyote.Processor. 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: AbstractHttp11Protocol.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * 调用 Http11Processor的构造方法.
 * @return
 */
@Override
protected Processor createProcessor() {
    //1.创建Http11处理器。
    Http11Processor processor = new Http11Processor(this, getEndpoint());
    //2.设置各种属性。
    //2.1 设置适配器。
    processor.setAdapter(getAdapter());
    //2.1 KeepAlive情况下 每个Socket处理的最多个请求次数(默认100)。
    processor.setMaxKeepAliveRequests(getMaxKeepAliveRequests());
    //2.2 设置KeepAlive的超时时间为300000ms。 == 300S.
    processor.setConnectionUploadTimeout(getConnectionUploadTimeout());
    //2.3 设置上传requestBody单独的超时时间。
    processor.setDisableUploadTimeout(getDisableUploadTimeout());
    //2.4 忽略。
    processor.setRestrictedUserAgents(getRestrictedUserAgents());
    //2.5 设置SSL相关缓冲区保存的Post的大小。
    processor.setMaxSavePostSize(getMaxSavePostSize());
    return processor;
}
 
Example #2
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled()) 
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled()) 
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example #3
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled()) 
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled()) 
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example #4
Source File: Http11NioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled())
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled())
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example #5
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketChannel socket) {
    if (log.isDebugEnabled())
        log.debug("Iterating through our connections to release a socket channel:"+socket);
    boolean released = false;
    Iterator<java.util.Map.Entry<NioChannel, Processor<NioChannel>>> it = connections.entrySet().iterator();
    while (it.hasNext()) {
        java.util.Map.Entry<NioChannel, Processor<NioChannel>> entry = it.next();
        if (entry.getKey().getIOChannel()==socket) {
            it.remove();
            Processor<NioChannel> result = entry.getValue();
            result.recycle(true);
            unregister(result);
            released = true;
            break;
        }
    }
    if (log.isDebugEnabled())
        log.debug("Done iterating through our connections to release a socket channel:"+socket +" released:"+released);
}
 
Example #6
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
        connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        if (!processor.isUpgrade()) {
            recycledProcessors.offer(processor);
        }
    }
}
 
Example #7
Source File: AbstractAjpProtocol.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected Processor createProcessor() {
    AjpProcessor processor = new AjpProcessor(getPacketSize(), getEndpoint());
    processor.setAdapter(getAdapter());
    processor.setAjpFlush(getAjpFlush());
    processor.setTomcatAuthentication(getTomcatAuthentication());
    processor.setTomcatAuthorization(getTomcatAuthorization());
    processor.setRequiredSecret(requiredSecret);
    processor.setKeepAliveTimeout(getKeepAliveTimeout());
    processor.setClientCertProvider(getClientCertProvider());
    processor.setSendReasonPhrase(getSendReasonPhrase());
    return processor;
}
 
Example #8
Source File: Http11AprProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated  Will be removed in Tomcat 8.0.x.
 */
@Deprecated
@Override
protected Processor<Long> createUpgradeProcessor(
        SocketWrapper<Long> socket,
        org.apache.coyote.http11.upgrade.UpgradeInbound inbound)
        throws IOException {
    return new org.apache.coyote.http11.upgrade.UpgradeAprProcessor(
            socket, inbound);
}
 
Example #9
Source File: Http11AprProtocol.java    From Tomcat7.0.67 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 #10
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
            connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        recycledProcessors.offer(processor);
    }
}
 
Example #11
Source File: AjpNioProtocol.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<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example #12
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 #13
Source File: Http11Protocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void initSsl(SocketWrapper<Socket> socket,
        Processor<Socket> processor) {
    if (proto.isSSLEnabled() && (proto.sslImplementation != null)) {
        processor.setSslSupport(
                proto.sslImplementation.getSSLSupport(
                        socket.getSocket()));
    } else {
        processor.setSslSupport(null);
    }

}
 
Example #14
Source File: Http11Protocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated  Will be removed in Tomcat 8.0.x.
 */
@Deprecated
@Override
protected Processor<Socket> createUpgradeProcessor(
        SocketWrapper<Socket> socket,
        org.apache.coyote.http11.upgrade.UpgradeInbound inbound)
        throws IOException {
    return new org.apache.coyote.http11.upgrade.UpgradeBioProcessor(
            socket, inbound);
}
 
Example #15
Source File: Http11Protocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected Processor<Socket> createUpgradeProcessor(
        SocketWrapper<Socket> socket,
        HttpUpgradeHandler httpUpgradeProcessor)
        throws IOException {
    return new BioProcessor(socket, httpUpgradeProcessor,
            proto.getUpgradeAsyncWriteBufferSize());
}
 
Example #16
Source File: Http11AprProtocol.java    From Tomcat7.0.67 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 #17
Source File: Http11NioProtocol.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.
 *
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example #18
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void initSsl(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor) {
    if (proto.isSSLEnabled() &&
            (proto.sslImplementation != null)
            && (socket.getSocket() instanceof SecureNioChannel)) {
        SecureNioChannel ch = (SecureNioChannel)socket.getSocket();
        processor.setSslSupport(
                proto.sslImplementation.getSSLSupport(
                        ch.getSslEngine().getSession()));
    } else {
        processor.setSslSupport(null);
    }

}
 
Example #19
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected void longPoll(SocketWrapper<NioChannel> socket,
        Processor<NioChannel> processor) {

    if (processor.isAsync()) {
        socket.setAsync(true);
    } else {
        // Either:
        //  - this is comet request
        //  - this is an upgraded connection
        //  - the request line/headers have not been completely
        //    read
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example #20
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated  Will be removed in Tomcat 8.0.x.
 */
@Deprecated
@Override
protected Processor<NioChannel> createUpgradeProcessor(
        SocketWrapper<NioChannel> socket,
        org.apache.coyote.http11.upgrade.UpgradeInbound inbound)
        throws IOException {
    return new org.apache.coyote.http11.upgrade.UpgradeNioProcessor(
            socket, inbound,
            ((Http11NioProtocol) getProtocol()).getEndpoint().getSelectorPool());
}
 
Example #21
Source File: Http11NioProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected Processor<NioChannel> createUpgradeProcessor(
        SocketWrapper<NioChannel> socket,
        HttpUpgradeHandler httpUpgradeProcessor)
        throws IOException {
    return new NioProcessor(socket, httpUpgradeProcessor,
            proto.getEndpoint().getSelectorPool(),
            proto.getUpgradeAsyncWriteBufferSize());
}
 
Example #22
Source File: Http11AprProtocol.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.
 * 
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller && proto.endpoint.isRunning()) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(), true, false);
    }
}
 
Example #23
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 #24
Source File: Http11AprProtocol.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated  Will be removed in Tomcat 8.0.x.
 */
@Deprecated
@Override
protected Processor<Long> createUpgradeProcessor(
        SocketWrapper<Long> socket,
        org.apache.coyote.http11.upgrade.UpgradeInbound inbound)
        throws IOException {
    return new org.apache.coyote.http11.upgrade.UpgradeAprProcessor(
            socket, inbound);
}
 
Example #25
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 #26
Source File: Http11AprProtocol.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.
 * 
 * @param socket
 * @param processor
 * @param isSocketClosing   Not used in HTTP
 * @param addToPoller
 */
@Override
public void release(SocketWrapper<Long> socket,
        Processor<Long> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller && proto.endpoint.isRunning()) {
        ((AprEndpoint)proto.endpoint).getPoller().add(
                socket.getSocket().longValue(),
                proto.endpoint.getKeepAliveTimeout(), true, false);
    }
}
 
Example #27
Source File: AbstractHttp11Protocol.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected Processor createUpgradeProcessor(
        SocketWrapperBase<?> socket,
        UpgradeToken upgradeToken) {
    HttpUpgradeHandler httpUpgradeHandler = upgradeToken.getHttpUpgradeHandler();
    if (httpUpgradeHandler instanceof InternalHttpUpgradeHandler) {
        return new UpgradeProcessorInternal(socket, upgradeToken);
    } else {
        return new UpgradeProcessorExternal(socket, upgradeToken);
    }
}
 
Example #28
Source File: AjpNioProtocol.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Expected to be used by the Poller to release resources on socket
 * close, errors etc.
 */
@Override
public void release(SocketWrapper<NioChannel> socket) {
    Processor<NioChannel> processor =
            connections.remove(socket.getSocket());
    if (processor != null) {
        processor.recycle(true);
        recycledProcessors.offer(processor);
    }
}
 
Example #29
Source File: AjpNioProtocol.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<NioChannel> socket,
        Processor<NioChannel> processor, boolean isSocketClosing,
        boolean addToPoller) {
    processor.recycle(isSocketClosing);
    recycledProcessors.offer(processor);
    if (addToPoller) {
        // The only time this method is called with addToPoller == true
        // is when the socket is in keep-alive so set the appropriate
        // timeout.
        socket.setTimeout(getProtocol().getKeepAliveTimeout());
        socket.getSocket().getPoller().add(socket.getSocket());
    }
}
 
Example #30
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);
    }
}