⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 http11protocol.java

📁 Tomcat 4.1与WebServer集成组件的源代码包.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ==================================================================== * * 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.http11;import java.io.InputStream;import java.io.IOException;import java.io.OutputStream;import org.apache.coyote.*;import java.io.*;import java.net.*;import java.util.*;import java.text.*;import org.apache.tomcat.util.res.StringManager;import org.apache.tomcat.util.IntrospectionUtils;import org.apache.tomcat.util.buf.*;import org.apache.tomcat.util.http.*;import org.apache.tomcat.util.log.*;import org.apache.tomcat.util.net.*;/** * Abstract the protocol implementation, including threading, etc. * Processor is single threaded and specific to stream-based protocols, * will not fit Jk protocols like JNI. * * @author Remy Maucherat * @author Costin Manolache */public class Http11Protocol implements ProtocolHandler{    /**     * The string manager for this package.     */    protected static StringManager sm =        StringManager.getManager(Constants.Package);    Adapter adapter;    Http11ConnectionHandler cHandler=new Http11ConnectionHandler( this );    /** Pass config info     */    public void setAttribute( String name, Object value ) {        log.debug(sm.getString("http11protocol.setattribute", name, value));        attributes.put(name, value);/*        if ("maxKeepAliveRequests".equals(name)) {            maxKeepAliveRequests = Integer.parseInt((String) value.toString());        } else if ("port".equals(name)) {            setPort(Integer.parseInt((String) value.toString()));        }*/    }    public Object getAttribute( String key ) {        return null;    }    /** The adapter, used to call the connector      */    public void setAdapter(Adapter adapter) {        this.adapter=adapter;    }    public Adapter getAdapter() {        return adapter;    }        /** Start the protocol     */    public void init() throws Exception {        ep.setConnectionHandler( cHandler );	try {            checkSocketFactory();        } catch( Exception ex ) {            log.error(sm.getString("http11protocol.socketfactory.initerror"),                       ex);            throw ex;        }        if( socketFactory!=null ) {            Enumeration attE=attributes.keys();            while( attE.hasMoreElements() ) {                String key=(String)attE.nextElement();                Object v=attributes.get( key );                socketFactory.setAttribute( key, v );            }        }        try {            ep.initEndpoint();        } catch (Exception ex) {            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);            throw ex;        }        log.info(sm.getString("http11protocol.init", "" + ep.getPort()));    }    public void start() throws Exception {        try {            ep.startEndpoint();        } catch (Exception ex) {            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);            throw ex;        }        log.info(sm.getString("http11protocol.start", "" + ep.getPort()));    }    public void destroy() throws Exception {        ep.stopEndpoint();    }        // -------------------- Properties--------------------    protected PoolTcpEndpoint ep=new PoolTcpEndpoint();    protected boolean secure;        protected ServerSocketFactory socketFactory;    protected SSLImplementation sslImplementation;    // socket factory attriubtes ( XXX replace with normal setters )     protected Hashtable attributes = new Hashtable();    protected String socketFactoryName=null;    protected String sslImplementationName=null;    private int maxKeepAliveRequests=100; // as in Apache HTTPD server    private int	timeout = 300000;	// 5 minutes as in Apache HTTPD server    private String reportedname;    private int socketCloseDelay=-1;    private boolean disableUploadTimeout = false;    private String compression = "off";    // -------------------- Pool setup --------------------    public void setPools( boolean t ) {	ep.setPoolOn(t);        setAttribute("pools", "" + t);    }    public void setMaxThreads( int maxThreads ) {	ep.setMaxThreads(maxThreads);        setAttribute("maxThreads", "" + maxThreads);    }    public void setMaxSpareThreads( int maxThreads ) {	ep.setMaxSpareThreads(maxThreads);        setAttribute("maxSpareThreads", "" + maxThreads);    }    public void setMinSpareThreads( int minSpareThreads ) {	ep.setMinSpareThreads(minSpareThreads);        setAttribute("minSpareThreads", "" + minSpareThreads);    }    // -------------------- Tcp setup --------------------    public void setBacklog( int i ) {	ep.setBacklog(i);        setAttribute("backlog", "" + i);    }        public void setPort( int port ) {	ep.setPort(port);        setAttribute("port", "" + port);    	//this.port=port;    }    public void setAddress(InetAddress ia) {	ep.setAddress( ia );        setAttribute("address", "" + ia);    }    public void setHostName( String name ) {	// ??? Doesn't seem to be used in existing or prev code	// vhost=name;    }    public void setSocketFactory( String valueS ) {	socketFactoryName = valueS;        setAttribute("socketFactory", valueS);    }    public void setSSLImplementation( String valueS) { 	sslImplementationName=valueS;        setAttribute("sslImplementation", valueS);    } 	    public void setTcpNoDelay( boolean b ) {	ep.setTcpNoDelay( b );        setAttribute("tcpNoDelay", "" + b);    }    public void setDisableUploadTimeout(boolean isDisabled) {        disableUploadTimeout = isDisabled;    }    public void setCompression(String valueS) {        compression = valueS;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -