FileDocCategorySizeDatePackage
Http11Protocol.javaAPI DocApache Tomcat 6.0.1425232Fri Jul 20 04:20:36 BST 2007org.apache.coyote.http11

Http11Protocol

public class Http11Protocol extends Object implements org.apache.coyote.ProtocolHandler, MBeanRegistration
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

Fields Summary
protected static org.apache.juli.logging.Log
log
protected static org.apache.tomcat.util.res.StringManager
sm
The string manager for this package.
protected Http11ConnectionHandler
cHandler
protected org.apache.tomcat.util.net.JIoEndpoint
endpoint
protected ObjectName
tpOname
protected ObjectName
rgOname
protected org.apache.tomcat.util.net.ServerSocketFactory
socketFactory
protected org.apache.tomcat.util.net.SSLImplementation
sslImplementation
protected HashMap
attributes
protected org.apache.coyote.Adapter
adapter
The adapter, used to call the connector.
protected int
processorCache
Processor cache.
protected int
socketBuffer
protected boolean
secure
This field indicates if the protocol is secure from the perspective of the client (= https is used).
protected boolean
SSLEnabled
protected String
socketFactoryName
Name of the socket factory.
protected String
sslImplementationName
Name of the SSL implementation.
protected int
maxKeepAliveRequests
Maximum number of requests which can be performed over a keepalive connection. The default is the same as for Apache HTTP Server.
protected int
keepAliveTimeout
The number of seconds Tomcat will wait for a subsequent request before closing the connection. The default is the same as for Apache HTTP Server (15 000 milliseconds).
protected int
timeout
This timeout represents the socket timeout which will be used while the adapter execution is in progress, unless disableUploadTimeout is set to true. The default is the same as for Apache HTTP Server (300 000 milliseconds).
protected int
maxSavePostSize
Maximum size of the post which will be saved when processing certain requests, such as a POST.
protected int
maxHttpHeaderSize
Maximum size of the HTTP message header.
protected boolean
disableUploadTimeout
If true, the regular socket timeout will be used for the full duration of the connection.
protected String
compression
Integrated compression support.
protected String
noCompressionUserAgents
protected String
compressableMimeTypes
protected int
compressionMinSize
protected String
restrictedUserAgents
User agents regular expressions which should be restricted to HTTP/1.0 support.
protected String
server
Server header.
protected String
domain
protected ObjectName
oname
protected MBeanServer
mserver
Constructors Summary
public Http11Protocol()



    // ------------------------------------------------------------ Constructor


      
        setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
        setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
        //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
        setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
    
Methods Summary
public voiddestroy()

        if (log.isInfoEnabled())
            log.info(sm.getString("http11protocol.stop", getName()));
        endpoint.destroy();
        if (tpOname!=null)
            Registry.getRegistry(null, null).unregisterComponent(tpOname);
        if (rgOname != null)
            Registry.getRegistry(null, null).unregisterComponent(rgOname);
    
public org.apache.coyote.AdaptergetAdapter()

 return adapter; 
public java.net.InetAddressgetAddress()

 return endpoint.getAddress(); 
public java.lang.StringgetAlgorithm()

        return (String) getAttribute("algorithm");
    
public java.lang.ObjectgetAttribute(java.lang.String key)

        return attributes.get(key);
    
public java.util.IteratorgetAttributeNames()

        return attributes.keySet().iterator();
    
public intgetBacklog()

 return endpoint.getBacklog(); 
public java.lang.StringgetCiphers()

        return (String) getAttribute("ciphers");
    
public java.lang.StringgetClientauth()

        return (String) getAttribute("clientauth");
    
public java.lang.StringgetCompressableMimeType()

        return compressableMimeTypes; 
public java.lang.StringgetCompression()

        return compression; 
public intgetCompressionMinSize()

        return compressionMinSize; 
public booleangetDisableUploadTimeout()

        return disableUploadTimeout; 
public java.lang.StringgetDomain()

        return domain;
    
public java.util.concurrent.ExecutorgetExecutor()

 return endpoint.getExecutor(); 
public booleangetKeepAlive()
Return the Keep-Alive policy for the connection.

        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
    
public intgetKeepAliveTimeout()

        return keepAliveTimeout; 
public java.lang.StringgetKeyAlias()

        return (String) getAttribute("keyAlias");
    
public java.lang.StringgetKeypass()

        return (String) getAttribute("keypass");
    
public java.lang.StringgetKeystore()

        return (String) getAttribute("keystore");
    
public java.lang.StringgetKeytype()

        return (String) getAttribute("keystoreType");
    
public intgetMaxHttpHeaderSize()

        return maxHttpHeaderSize; 
public intgetMaxKeepAliveRequests()

        return maxKeepAliveRequests; 
public intgetMaxSavePostSize()

        return maxSavePostSize; 
public intgetMaxThreads()

 return endpoint.getMaxThreads(); 
public java.lang.StringgetName()

        String encodedAddr = "";
        if (getAddress() != null) {
            encodedAddr = "" + getAddress();
            if (encodedAddr.startsWith("/"))
                encodedAddr = encodedAddr.substring(1);
            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
        }
        return ("http-" + encodedAddr + endpoint.getPort());
    
public java.lang.StringgetNoCompressionUserAgents()

        return noCompressionUserAgents; 
public javax.management.ObjectNamegetObjectName()

        return oname;
    
public intgetPort()

 return endpoint.getPort(); 
public intgetProcessorCache()

        return this.processorCache; 
public java.lang.StringgetProperty(java.lang.String name)
Get a property

        return (String)getAttribute(name);
    
public java.lang.StringgetProtocols()

        return (String) getAttribute("protocols");
    
public java.lang.StringgetRestrictedUserAgents()

        return restrictedUserAgents; 
public java.lang.StringgetSSLImplementation()

        return sslImplementationName; 
public booleangetSecure()

 return secure; 
public java.lang.StringgetServer()

 return server; 
public intgetSoLinger()

 return endpoint.getSoLinger(); 
public intgetSoTimeout()

 return endpoint.getSoTimeout(); 
public intgetSocketBuffer()

        return socketBuffer; 
public java.lang.StringgetSocketFactory()

        return socketFactoryName; 
public booleangetTcpNoDelay()

 return endpoint.getTcpNoDelay(); 
public intgetThreadPriority()

 return endpoint.getThreadPriority(); 
public intgetTimeout()

        return timeout; 
public voidinit()

        endpoint.setName(getName());
        endpoint.setHandler(cHandler);

        // Verify the validity of the configured socket factory
        try {
            if (isSSLEnabled()) {
                sslImplementation =
                    SSLImplementation.getInstance(sslImplementationName);
                socketFactory = sslImplementation.getServerSocketFactory();
                endpoint.setServerSocketFactory(socketFactory);
            } else if (socketFactoryName != null) {
                socketFactory = (ServerSocketFactory) Class.forName(socketFactoryName).newInstance();
                endpoint.setServerSocketFactory(socketFactory);
            }
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.socketfactory.initerror"),
                      ex);
            throw ex;
        }

        if (socketFactory!=null) {
            Iterator<String> attE = attributes.keySet().iterator();
            while( attE.hasNext() ) {
                String key = attE.next();
                Object v=attributes.get(key);
                socketFactory.setAttribute(key, v);
            }
        }
        
        try {
            endpoint.init();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);
            throw ex;
        }
        if (log.isInfoEnabled())
            log.info(sm.getString("http11protocol.init", getName()));

    
public booleanisSSLEnabled()

        return SSLEnabled;
public voidpause()

        try {
            endpoint.pause();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
            throw ex;
        }
        if (log.isInfoEnabled())
            log.info(sm.getString("http11protocol.pause", getName()));
    
public voidpostDeregister()

    
public voidpostRegister(java.lang.Boolean registrationDone)

    
public voidpreDeregister()

    
public javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName name)

        oname=name;
        mserver=server;
        domain=name.getDomain();
        return name;
    
public voidresume()

        try {
            endpoint.resume();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
            throw ex;
        }
        if (log.isInfoEnabled())
            log.info(sm.getString("http11protocol.resume", getName()));
    
public voidsetAdapter(org.apache.coyote.Adapter adapter)

 this.adapter = adapter; 
public voidsetAddress(java.net.InetAddress ia)

 endpoint.setAddress(ia); 
public voidsetAlgorithm(java.lang.String k)

        setAttribute("algorithm", k);
    
public voidsetAttribute(java.lang.String name, java.lang.Object value)
Pass config info

        if (log.isTraceEnabled()) {
            log.trace(sm.getString("http11protocol.setattribute", name, value));
        }
        attributes.put(name, value);
    
public voidsetBacklog(int backlog)

 endpoint.setBacklog(backlog); 
public voidsetCiphers(java.lang.String ciphers)

        setAttribute("ciphers", ciphers);
    
public voidsetClientauth(java.lang.String k)

        setAttribute("clientauth", k);
    
public voidsetCompressableMimeType(java.lang.String valueS)

 compressableMimeTypes = valueS; 
public voidsetCompression(java.lang.String valueS)

 compression = valueS; 
public voidsetCompressionMinSize(int valueI)

 compressionMinSize = valueI; 
public voidsetDisableUploadTimeout(boolean isDisabled)

 disableUploadTimeout = isDisabled; 
public voidsetExecutor(java.util.concurrent.Executor executor)

 endpoint.setExecutor(executor); 
public voidsetKeepAlive(boolean keepAlive)
Set the keep-alive policy for this connection.

        if (!keepAlive) {
            setMaxKeepAliveRequests(1);
        }
    
public voidsetKeepAliveTimeout(int timeout)

 keepAliveTimeout = timeout; 
public voidsetKeyAlias(java.lang.String keyAlias)

        setAttribute("keyAlias", keyAlias);
    
public voidsetKeypass(java.lang.String k)

        attributes.put("keypass", k);
        //setAttribute("keypass", k);
    
public voidsetKeystore(java.lang.String k)

        setAttribute("keystore", k);
    
public voidsetKeytype(java.lang.String k)

        setAttribute("keystoreType", k);
    
public voidsetMaxHttpHeaderSize(int valueI)

 maxHttpHeaderSize = valueI; 
public voidsetMaxKeepAliveRequests(int mkar)

 maxKeepAliveRequests = mkar; 
public voidsetMaxSavePostSize(int valueI)

 maxSavePostSize = valueI; 
public voidsetMaxThreads(int maxThreads)

 endpoint.setMaxThreads(maxThreads); 
public voidsetNoCompressionUserAgents(java.lang.String valueS)

 noCompressionUserAgents = valueS; 
public voidsetPort(int port)

 endpoint.setPort(port); 
public voidsetProcessorCache(int processorCache)

 this.processorCache = processorCache; 
public voidsetProperty(java.lang.String name, java.lang.String value)
Set a property.


    
            
          
        setAttribute(name, value);
    
public voidsetProtocols(java.lang.String k)

        setAttribute("protocols", k);
    
public voidsetRestrictedUserAgents(java.lang.String valueS)

 restrictedUserAgents = valueS; 
public voidsetSSLEnabled(boolean SSLEnabled)

this.SSLEnabled = SSLEnabled;
public voidsetSSLImplementation(java.lang.String valueS)

        sslImplementationName = valueS;
        setSecure(true);
    
public voidsetSecure(boolean b)

 secure = b; 
public voidsetServer(java.lang.String server)

 this.server = server; 
public voidsetSoLinger(int soLinger)

 endpoint.setSoLinger(soLinger); 
public voidsetSoTimeout(int soTimeout)

 endpoint.setSoTimeout(soTimeout); 
public voidsetSocketBuffer(int socketBuffer)

 this.socketBuffer = socketBuffer; 
public voidsetSocketFactory(java.lang.String valueS)

 socketFactoryName = valueS; 
public voidsetTcpNoDelay(boolean tcpNoDelay)

 endpoint.setTcpNoDelay(tcpNoDelay); 
public voidsetThreadPriority(int threadPriority)

 endpoint.setThreadPriority(threadPriority); 
public voidsetTimeout(int timeout)

 this.timeout = timeout; 
public voidstart()

        if (this.domain != null) {
            try {
                tpOname = new ObjectName
                    (domain + ":" + "type=ThreadPool,name=" + getName());
                Registry.getRegistry(null, null)
                    .registerComponent(endpoint, tpOname, null );
            } catch (Exception e) {
                log.error("Can't register endpoint");
            }
            rgOname=new ObjectName
                (domain + ":type=GlobalRequestProcessor,name=" + getName());
            Registry.getRegistry(null, null).registerComponent
                ( cHandler.global, rgOname, null );
        }

        try {
            endpoint.start();
        } catch (Exception ex) {
            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
            throw ex;
        }
        if (log.isInfoEnabled())
            log.info(sm.getString("http11protocol.start", getName()));