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

📄 http11protocol.java

📁 业界著名的tomcat服务器的最新6.0的源代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

    
    // HTTP
    protected String compressableMimeTypes = "text/html,text/xml,text/plain";
    public String getCompressableMimeType() { return compressableMimeTypes; }
    public void setCompressableMimeType(String valueS) { compressableMimeTypes = valueS; }
    
    
    // HTTP
    protected int compressionMinSize = 2048;
    public int getCompressionMinSize() { return compressionMinSize; }
    public void setCompressionMinSize(int valueI) { compressionMinSize = valueI; }


    // HTTP
    /**
     * User agents regular expressions which should be restricted to HTTP/1.0 support.
     */
    protected String restrictedUserAgents = null;
    public String getRestrictedUserAgents() { return restrictedUserAgents; }
    public void setRestrictedUserAgents(String valueS) { restrictedUserAgents = valueS; }
    
    
    // HTTP
    /**
     * Server header.
     */
    protected String server;
    public void setServer( String server ) { this.server = server; }
    public String getServer() { return server; }


    // --------------------------------------------------------- Public methods

    // *
    public Executor getExecutor() {
        return endpoint.getExecutor();
    }
    
    // *
    public void setExecutor(Executor executor) {
        endpoint.setExecutor(executor);
    }
    
    // *
    public int getMaxThreads() {
        return endpoint.getMaxThreads();
    }

    // *
    public void setMaxThreads( int maxThreads ) {
        endpoint.setMaxThreads(maxThreads);
    }

    // *
    public void setThreadPriority(int threadPriority) {
        endpoint.setThreadPriority(threadPriority);
    }

    // *
    public int getThreadPriority() {
        return endpoint.getThreadPriority();
    }

    // *
    public int getBacklog() {
        return endpoint.getBacklog();
    }

    // *
    public void setBacklog( int i ) {
        endpoint.setBacklog(i);
    }

    // *
    public int getPort() {
        return endpoint.getPort();
    }

    // *
    public void setPort( int port ) {
        endpoint.setPort(port);
    }

    // *
    public InetAddress getAddress() {
        return endpoint.getAddress();
    }

    // *
    public void setAddress(InetAddress ia) {
        endpoint.setAddress( ia );
    }

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

    // *
    public boolean getTcpNoDelay() {
        return endpoint.getTcpNoDelay();
    }

    // *
    public void setTcpNoDelay( boolean b ) {
        endpoint.setTcpNoDelay( b );
    }

    // *
    public int getSoLinger() {
        return endpoint.getSoLinger();
    }

    // *
    public void setSoLinger( int i ) {
        endpoint.setSoLinger( i );
    }

    // *
    public int getSoTimeout() {
        return endpoint.getSoTimeout();
    }

    // *
    public void setSoTimeout( int i ) {
        endpoint.setSoTimeout(i);
    }

    // HTTP
    /**
     * Return the Keep-Alive policy for the connection.
     */
    public boolean getKeepAlive() {
        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
    }

    // HTTP
    /**
     * Set the keep-alive policy for this connection.
     */
    public void setKeepAlive(boolean keepAlive) {
        if (!keepAlive) {
            setMaxKeepAliveRequests(1);
        }
    }

    /*
     * Note: All the following are JSSE/java.io specific attributes.
     */
    
    public String getKeystore() {
        return (String) getAttribute("keystore");
    }

    public void setKeystore( String k ) {
        setAttribute("keystore", k);
    }

    public String getKeypass() {
        return (String) getAttribute("keypass");
    }

    public void setKeypass( String k ) {
        attributes.put("keypass", k);
        //setAttribute("keypass", k);
    }

    public String getKeytype() {
        return (String) getAttribute("keystoreType");
    }

    public void setKeytype( String k ) {
        setAttribute("keystoreType", k);
    }

    public String getClientauth() {
        return (String) getAttribute("clientauth");
    }

    public void setClientauth( String k ) {
        setAttribute("clientauth", k);
    }

    public String getProtocols() {
        return (String) getAttribute("protocols");
    }

    public void setProtocols(String k) {
        setAttribute("protocols", k);
    }

    public String getAlgorithm() {
        return (String) getAttribute("algorithm");
    }

    public void setAlgorithm( String k ) {
        setAttribute("algorithm", k);
    }

    public String getCiphers() {
        return (String) getAttribute("ciphers");
    }

    public void setCiphers(String ciphers) {
        setAttribute("ciphers", ciphers);
    }

    public String getKeyAlias() {
        return (String) getAttribute("keyAlias");
    }

    public void setKeyAlias(String keyAlias) {
        setAttribute("keyAlias", keyAlias);
    }

    // -----------------------------------  Http11ConnectionHandler Inner Class

    protected static class Http11ConnectionHandler implements Handler {
        protected Http11Protocol protocol;
        protected static int count = 0;
        protected RequestGroupInfo global = new RequestGroupInfo();
        protected ThreadLocal<Http11Processor> localProcessor = new ThreadLocal<Http11Processor>();

        Http11ConnectionHandler(Http11Protocol proto) {
            this.protocol = proto;
        }

        public boolean process(Socket socket) {
            Http11Processor processor = null;
            try {
                processor = localProcessor.get();
                if (processor == null) {
                    processor =
                        new Http11Processor(protocol.maxHttpHeaderSize, protocol.endpoint);
                    processor.setAdapter(protocol.adapter);
                    processor.setMaxKeepAliveRequests(protocol.maxKeepAliveRequests);
                    processor.setKeepAliveTimeout(protocol.keepAliveTimeout);
                    processor.setTimeout(protocol.timeout);
                    processor.setDisableUploadTimeout(protocol.disableUploadTimeout);
                    processor.setCompression(protocol.compression);
                    processor.setCompressionMinSize(protocol.compressionMinSize);
                    processor.setNoCompressionUserAgents(protocol.noCompressionUserAgents);
                    processor.setCompressableMimeTypes(protocol.compressableMimeTypes);
                    processor.setRestrictedUserAgents(protocol.restrictedUserAgents);
                    processor.setMaxSavePostSize(protocol.maxSavePostSize);
                    processor.setServer(protocol.server);
                    localProcessor.set(processor);
                    if (protocol.getDomain() != null) {
                        synchronized (this) {
                            try {
                                RequestInfo rp = processor.getRequest().getRequestProcessor();
                                rp.setGlobalProcessor(global);
                                ObjectName rpName = new ObjectName
                                (protocol.getDomain() + ":type=RequestProcessor,worker="
                                        + protocol.getName() + ",name=HttpRequest" + count++);
                                Registry.getRegistry(null, null).registerComponent(rp, rpName, null);
                            } catch (Exception e) {
                                log.warn("Error registering request");
                            }
                        }
                    }
                }

                if (processor instanceof ActionHook) {
                    ((ActionHook) processor).action(ActionCode.ACTION_START, null);
                }

                if (protocol.secure && (protocol.sslImplementation != null)) {
                    processor.setSSLSupport
                        (protocol.sslImplementation.getSSLSupport(socket));
                } else {
                    processor.setSSLSupport(null);
                }
                
                processor.process(socket);
                return false;

            } catch(java.net.SocketException e) {
                // SocketExceptions are normal
                Http11Protocol.log.debug
                    (sm.getString
                     ("http11protocol.proto.socketexception.debug"), e);
            } catch (java.io.IOException e) {
                // IOExceptions are normal
                Http11Protocol.log.debug
                    (sm.getString
                     ("http11protocol.proto.ioexception.debug"), e);
            }
            // Future developers: if you discover any other
            // rare-but-nonfatal exceptions, catch them here, and log as
            // above.
            catch (Throwable e) {
                // any other exception or error is odd. Here we log it
                // with "ERROR" level, so it will show up even on
                // less-than-verbose logs.
                Http11Protocol.log.error
                    (sm.getString("http11protocol.proto.error"), e);
            } finally {
                //       if(proto.adapter != null) proto.adapter.recycle();
                //                processor.recycle();

                if (processor instanceof ActionHook) {
                    ((ActionHook) processor).action(ActionCode.ACTION_STOP, null);
                }
            }
            return false;
        }
    }


    // -------------------- JMX related methods --------------------

    // *
    protected String domain;
    protected ObjectName oname;
    protected MBeanServer mserver;

    public ObjectName getObjectName() {
        return oname;
    }

    public String getDomain() {
        return domain;
    }

    public ObjectName preRegister(MBeanServer server,
                                  ObjectName name) throws Exception {
        oname=name;
        mserver=server;
        domain=name.getDomain();
        return name;
    }

    public void postRegister(Boolean registrationDone) {
    }

    public void preDeregister() throws Exception {
    }

    public void postDeregister() {
    }
}

⌨️ 快捷键说明

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