📄 coyoteconnector.java
字号:
/* * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java,v 1.20.2.1 2003/02/09 22:30:02 remm Exp $ * $Revision: 1.20.2.1 $ * $Date: 2003/02/09 22:30:02 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */package org.apache.coyote.tomcat4;import java.io.IOException;import java.net.InetAddress;import java.net.ServerSocket;import java.net.Socket;import java.net.UnknownHostException;import java.security.AccessControlException;import java.util.Stack;import java.util.Vector;import java.util.Enumeration;import java.security.KeyStoreException;import java.security.NoSuchAlgorithmException;import java.security.cert.CertificateException;import java.security.UnrecoverableKeyException;import java.security.KeyManagementException;import org.apache.tomcat.util.IntrospectionUtils;import org.apache.coyote.ActionCode;import org.apache.coyote.ActionHook;import org.apache.coyote.Adapter;import org.apache.coyote.InputBuffer;import org.apache.coyote.OutputBuffer;import org.apache.coyote.ProtocolHandler;import org.apache.catalina.Connector;import org.apache.catalina.Container;import org.apache.catalina.HttpRequest;import org.apache.catalina.HttpResponse;import org.apache.catalina.Lifecycle;import org.apache.catalina.LifecycleEvent;import org.apache.catalina.LifecycleException;import org.apache.catalina.LifecycleListener;import org.apache.catalina.Logger;import org.apache.catalina.Request;import org.apache.catalina.Response;import org.apache.catalina.Service;import org.apache.catalina.net.DefaultServerSocketFactory;import org.apache.catalina.net.ServerSocketFactory;import org.apache.catalina.util.LifecycleSupport;import org.apache.catalina.util.StringManager;/** * Implementation of a Coyote connector for Tomcat 4.x. * * @author Craig R. McClanahan * @author Remy Maucherat * @version $Revision: 1.20.2.1 $ $Date: 2003/02/09 22:30:02 $ */public final class CoyoteConnector implements Connector, Lifecycle { // ----------------------------------------------------- Instance Variables /** * The <code>Service</code> we are associated with (if any). */ private Service service = null; /** * The accept count for this Connector. */ private int acceptCount = 10; /** * The IP address on which to bind, if any. If <code>null</code>, all * addresses on the server will be bound. */ private String address = null; /** * The input buffer size we should create on input streams. */ private int bufferSize = 2048; /** * The Container used for processing requests received by this Connector. */ protected Container container = null; /** * The set of processors that have ever been created. */ private Vector created = new Vector(); /** * The current number of processors that have been created. */ private int curProcessors = 0; /** * The debugging detail level for this component. */ private int debug = 0; /** * The "enable DNS lookups" flag for this Connector. */ private boolean enableLookups = false; /** * The server socket factory for this component. */ private ServerSocketFactory factory = null; /** * Descriptive information about this Connector implementation. */ private static final String info = "org.apache.coyote.tomcat4.CoyoteConnector2/1.0"; /** * The lifecycle event support for this component. */ protected LifecycleSupport lifecycle = new LifecycleSupport(this); /** * The minimum number of processors to start at initialization time. */ protected int minProcessors = 5; /** * The maximum number of processors allowed, or <0 for unlimited. */ private int maxProcessors = 20; /** * Linger value on the incoming connection. * Note : a value inferior to 0 means no linger. */ private int connectionLinger = Constants.DEFAULT_CONNECTION_LINGER; /** * Timeout value on the incoming connection. * Note : a value of 0 means no timeout. */ private int connectionTimeout = Constants.DEFAULT_CONNECTION_TIMEOUT; /** * The port number on which we listen for requests. */ private int port = 8080; /** * The server name to which we should pretend requests to this Connector * were directed. This is useful when operating Tomcat behind a proxy * server, so that redirects get constructed accurately. If not specified, * the server name included in the <code>Host</code> header is used. */ private String proxyName = null; /** * The server port to which we should pretent requests to this Connector * were directed. This is useful when operating Tomcat behind a proxy * server, so that redirects get constructed accurately. If not specified, * the port number specified by the <code>port</code> property is used. */ private int proxyPort = 0; /** * The redirect port for non-SSL to SSL redirects. */ private int redirectPort = 443; /** * The request scheme that will be set on all requests received * through this connector. */ private String scheme = "http"; /** * The secure connection flag that will be set on all requests received * through this connector. */ private boolean secure = false; /** * The string manager for this package. */ private StringManager sm = StringManager.getManager(Constants.Package); /** * Has this component been initialized yet? */ private boolean initialized = false; /** * Has this component been started yet? */ private boolean started = false; /** * The shutdown signal to our background thread */ private boolean stopped = false; /** * The background thread. */ private Thread thread = null; /** * Use TCP no delay ? */ private boolean tcpNoDelay = true; /** * Flag to disable setting a seperate time-out for uploads. * If <code>true</code>, then the <code>timeout</code> parameter is * ignored. If <code>false</code>, then the <code>timeout</code> * parameter is used to control uploads. */ private boolean disableUploadTimeout = false; /** * Maximum number of Keep-Alive requests to honor per connection. */ private int maxKeepAliveRequests = 100; /** * Compression value. */ private String compression = "off"; /** * Coyote Protocol handler class name. * Defaults to the Coyote HTTP/1.1 protocolHandler. */ private String protocolHandlerClassName = "org.apache.coyote.http11.Http11Protocol"; /** * Use URI validation for Tomcat 4.0.x. */ private boolean useURIValidationHack = true; /** * Coyote protocol handler. */ private ProtocolHandler protocolHandler = null; /** * Coyote adapter. */ private Adapter adapter = null; // ------------------------------------------------------------- Properties /** * Return the <code>Service</code> with which we are associated (if any). */ public Service getService() { return (this.service); } /** * Set the <code>Service</code> with which we are associated (if any). * * @param service The service that owns this Engine */ public void setService(Service service) { this.service = service; } /** * Return the connection linger for this Connector. */ public int getConnectionLinger() { return (connectionLinger); } /** * Set the connection linger for this Connector. * * @param count The new connection linge */ public void setConnectionLinger(int connectionLinger) { this.connectionLinger = connectionLinger; } /** * Return the connection timeout for this Connector. */ public int getConnectionTimeout() { return (connectionTimeout); } /** * Set the connection timeout for this Connector. * * @param count The new connection timeout */ public void setConnectionTimeout(int connectionTimeout) { this.connectionTimeout = connectionTimeout; } /** * Return the accept count for this Connector. */ public int getAcceptCount() { return (acceptCount); } /** * Set the accept count for this Connector. * * @param count The new accept count */ public void setAcceptCount(int count) { this.acceptCount = count; } /** * Return the bind IP address for this Connector. */ public String getAddress() { return (this.address); } /** * Set the bind IP address for this Connector. * * @param address The bind IP address */ public void setAddress(String address) { this.address = address; } /** * Is this connector available for processing requests? */ public boolean isAvailable() { return (started); } /** * Return the input buffer size for this Connector. */ public int getBufferSize() { return (this.bufferSize); } /** * Set the input buffer size for this Connector. * * @param bufferSize The new input buffer size. */ public void setBufferSize(int bufferSize) { this.bufferSize = bufferSize; } /** * Return the Container used for processing requests received by this * Connector. */ public Container getContainer() { return (container); } /** * Set the Container used for processing requests received by this * Connector. * * @param container The new Container to use */ public void setContainer(Container container) { this.container = container; } /** * Get the value of compression. */ public String getCompression() { return (compression); } /** * Set the value of compression. * * @param compression The new compression value, which can be "on", "off" * or "force" */ public void setCompression(String compression) { this.compression = compression; } /** * Return the current number of processors that have been created. */ public int getCurProcessors() { return (curProcessors); } /** * Return the debugging detail level for this component. */ public int getDebug() { return (debug); } /** * Set the debugging detail level for this component. * * @param debug The new debugging detail level */ public void setDebug(int debug) { this.debug = debug; } /** * Return the "enable DNS lookups" flag. */ public boolean getEnableLookups() { return (this.enableLookups); } /** * Set the "enable DNS lookups" flag. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -