📄 http11protocol.java
字号:
public void setSoLinger( int i ) { ep.setSoLinger( i ); setAttribute("soLinger", "" + i); } public void setSoTimeout( int i ) { ep.setSoTimeout(i); setAttribute("soTimeout", "" + i); } public void setServerSoTimeout( int i ) { ep.setServerSoTimeout(i); setAttribute("serverSoTimeout", "" + i); } public void setKeystore( String k ) { setAttribute("keystore", k); } public void setKeypass( String k ) { attributes.put("keypass", k); //setAttribute("keypass", k); } public void setKeytype( String k ) { setAttribute("keystoreType", k); } public void setClientauth( String k ) { setAttribute("clientauth", k); } public void setProtocol( String k ) { setAttribute("protocol", k); } public void setAlgorithm( String k ) { setAttribute("algorithm", k); } public void setSecure( boolean b ) { secure=b; setAttribute("secure", "" + b); } /** Set the maximum number of Keep-Alive requests that we will honor. */ public void setMaxKeepAliveRequests(int mkar) { maxKeepAliveRequests = mkar; setAttribute("maxKeepAliveRequests", "" + mkar); } public void setSocketCloseDelay( int d ) { socketCloseDelay=d; setAttribute("socketCloseDelay", "" + d); } private static ServerSocketFactory string2SocketFactory( String val) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class chC=Class.forName( val ); return (ServerSocketFactory)chC.newInstance(); } public void setTimeout( int timeouts ) { timeout = timeouts * 1000; setAttribute("timeout", "" + timeouts); } public void setReportedname( String reportedName) { reportedname = reportedName; } // -------------------- Connection handler -------------------- static class Http11ConnectionHandler implements TcpConnectionHandler { Http11Protocol proto; Http11ConnectionHandler( Http11Protocol proto ) { this.proto=proto; } public void setAttribute( String name, Object value ) { } public void setServer( Object o ) { } public Object[] init() { Object thData[]=new Object[3]; //CoyoteProcessor adaptor = new CoyoteProcessor(cm); // XXX Should be on request // if( proto.secure ) // proto.adapter.setSSLImplementation(proto.sslImplementation); Http11Processor processor = new Http11Processor(); processor.setAdapter( proto.adapter ); processor.setMaxKeepAliveRequests( proto.maxKeepAliveRequests ); processor.setTimeout( proto.timeout ); processor.setDisableUploadTimeout( proto.disableUploadTimeout ); processor.setCompression( proto.compression ); //thData[0]=adapter; thData[1]=processor; thData[2]=null; return thData; } public void processConnection(TcpConnection connection, Object thData[]) { Socket socket=null; Http11Processor processor=null; try { processor=(Http11Processor)thData[1]; if (processor instanceof ActionHook) { ((ActionHook) processor).action(ActionCode.ACTION_START, null); } socket=connection.getSocket(); InputStream in = socket.getInputStream(); OutputStream out = socket.getOutputStream(); if( proto.secure ) { SSLSupport sslSupport=null; if(proto.sslImplementation != null) sslSupport = proto.sslImplementation.getSSLSupport(socket); processor.setSSLSupport(sslSupport); } else { processor.setSSLSupport( null ); } processor.setSocket( socket ); processor.process(in, out); // If unread input arrives after the shutdownInput() call // below and before or during the socket.close(), an error // may be reported to the client. To help troubleshoot this // type of error, provide a configurable delay to give the // unread input time to arrive so it can be successfully read // and discarded by shutdownInput(). if( proto.socketCloseDelay >= 0 ) { try { Thread.sleep(proto.socketCloseDelay); } catch (InterruptedException ie) { /* ignore */ } } TcpConnection.shutdownInput( socket ); } catch(java.net.SocketException e) { // SocketExceptions are normal proto.log.debug (sm.getString ("http11protocol.proto.socketexception.debug"), e); } catch (java.io.IOException e) { // IOExceptions are normal proto.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. proto.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); } // recycle kernel sockets ASAP try { if (socket != null) socket.close (); } catch (IOException e) { /* ignore */ } } } } protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Http11Protocol.class); // -------------------- Various implementation classes -------------------- /** Sanity check and socketFactory setup. * IMHO it is better to stop the show on a broken connector, * then leave Tomcat running and broken. * @exception TomcatException Unable to resolve classes */ private void checkSocketFactory() throws Exception { if(secure) { try { // The SSL setup code has been moved into // SSLImplementation since SocketFactory doesn't // provide a wide enough interface sslImplementation=SSLImplementation.getInstance (sslImplementationName); socketFactory = sslImplementation.getServerSocketFactory(); ep.setServerSocketFactory(socketFactory); } catch (ClassNotFoundException e){ throw e; } } else { if (socketFactoryName != null) { try { socketFactory = string2SocketFactory(socketFactoryName); ep.setServerSocketFactory(socketFactory); } catch(Exception sfex) { throw sfex; } } } } /* public int getPort() { return ep.getPort(); } public InetAddress getAddress() { return ep.getAddress(); } public boolean isKeystoreSet() { return (attributes.get("keystore") != null); } public boolean isKeypassSet() { return (attributes.get("keypass") != null); } public boolean isClientauthSet() { return (attributes.get("clientauth") != null); } public boolean isAttributeSet( String attr ) { return (attributes.get(attr) != null); } public boolean isSecure() { return secure; } public PoolTcpEndpoint getEndpoint() { return ep; } */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -