📄 http11baseprotocol.java
字号:
maxHttpHeaderSize = valueI;
setAttribute("maxHttpHeaderSize", "" + valueI);
}
public String getRestrictedUserAgents() {
return restrictedUserAgents;
}
public void setRestrictedUserAgents(String valueS) {
restrictedUserAgents = valueS;
setAttribute("restrictedUserAgents", valueS);
}
public String getNoCompressionUserAgents() {
return noCompressionUserAgents;
}
public void setNoCompressionUserAgents(String valueS) {
noCompressionUserAgents = valueS;
setAttribute("noCompressionUserAgents", valueS);
}
public String getCompressableMimeType() {
return compressableMimeTypes;
}
public void setCompressableMimeType(String valueS) {
compressableMimeTypes = valueS;
setAttribute("compressableMimeTypes", valueS);
}
public int getCompressionMinSize() {
return compressionMinSize;
}
public void setCompressionMinSize(int valueI) {
compressionMinSize = valueI;
setAttribute("compressionMinSize", "" + valueI);
}
public int getSoLinger() {
return ep.getSoLinger();
}
public void setSoLinger( int i ) {
ep.setSoLinger( i );
setAttribute("soLinger", "" + i);
}
public int getSoTimeout() {
return ep.getSoTimeout();
}
public void setSoTimeout( int i ) {
ep.setSoTimeout(i);
setAttribute("soTimeout", "" + i);
}
public int getServerSoTimeout() {
return ep.getServerSoTimeout();
}
public void setServerSoTimeout( int i ) {
ep.setServerSoTimeout(i);
setAttribute("serverSoTimeout", "" + i);
}
public String getKeystore() {
return getProperty("keystore");
}
public void setKeystore( String k ) {
setAttribute("keystore", k);
}
public String getKeypass() {
return getProperty("keypass");
}
public void setKeypass( String k ) {
attributes.put("keypass", k);
//setAttribute("keypass", k);
}
public String getKeytype() {
return getProperty("keystoreType");
}
public void setKeytype( String k ) {
setAttribute("keystoreType", k);
}
public String getClientauth() {
return getProperty("clientauth");
}
public void setClientauth( String k ) {
setAttribute("clientauth", k);
}
public String getProtocol() {
return getProperty("protocol");
}
public void setProtocol( String k ) {
setSecure(true);
setAttribute("protocol", k);
}
public String getProtocols() {
return getProperty("protocols");
}
public void setProtocols(String k) {
setAttribute("protocols", k);
}
public String getAlgorithm() {
return getProperty("algorithm");
}
public void setAlgorithm( String k ) {
setAttribute("algorithm", k);
}
public boolean getSecure() {
return secure;
}
public void setSecure( boolean b ) {
secure=b;
setAttribute("secure", "" + b);
}
public String getCiphers() {
return getProperty("ciphers");
}
public void setCiphers(String ciphers) {
setAttribute("ciphers", ciphers);
}
public String getKeyAlias() {
return getProperty("keyAlias");
}
public void setKeyAlias(String keyAlias) {
setAttribute("keyAlias", keyAlias);
}
public int getMaxKeepAliveRequests() {
return maxKeepAliveRequests;
}
/** Set the maximum number of Keep-Alive requests that we will honor.
*/
public void setMaxKeepAliveRequests(int mkar) {
maxKeepAliveRequests = mkar;
setAttribute("maxKeepAliveRequests", "" + mkar);
}
/**
* Return the Keep-Alive policy for the connection.
*/
public boolean getKeepAlive() {
return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
}
/**
* Set the keep-alive policy for this connection.
*/
public void setKeepAlive(boolean keepAlive) {
if (!keepAlive) {
setMaxKeepAliveRequests(1);
}
}
public int getSocketCloseDelay() {
return socketCloseDelay;
}
public void setSocketCloseDelay( int d ) {
socketCloseDelay=d;
setAttribute("socketCloseDelay", "" + d);
}
public void setServer( String server ) {
this.server = server;
}
public String getServer() {
return server;
}
private static ServerSocketFactory string2SocketFactory( String val)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException
{
Class chC=Class.forName( val );
return (ServerSocketFactory)chC.newInstance();
}
public int getTimeout() {
return timeout;
}
public void setTimeout( int timeouts ) {
timeout = timeouts;
setAttribute("timeout", "" + timeouts);
}
public String getReportedname() {
return reportedname;
}
public void setReportedname( String reportedName) {
reportedname = reportedName;
}
// -------------------- Connection handler --------------------
public static final int THREAD_DATA_PROCESSOR=1;
public static final int THREAD_DATA_OBJECT_NAME=2;
static class Http11ConnectionHandler implements TcpConnectionHandler {
Http11BaseProtocol proto;
static int count=0;
RequestGroupInfo global=new RequestGroupInfo();
Http11ConnectionHandler( Http11BaseProtocol proto ) {
this.proto=proto;
}
public void setAttribute( String name, Object value ) {
}
public void setServer( Object o ) {
}
public Object[] init() {
Object thData[]=new Object[3];
Http11Processor processor =
new Http11Processor(proto.maxHttpHeaderSize);
processor.setAdapter( proto.adapter );
processor.setThreadPool( proto.tp );
processor.setEndpoint( proto.ep );
processor.setMaxKeepAliveRequests( proto.maxKeepAliveRequests );
processor.setTimeout( proto.timeout );
processor.setDisableUploadTimeout( proto.disableUploadTimeout );
processor.setCompression( proto.compression );
processor.setCompressionMinSize( proto.compressionMinSize);
processor.setNoCompressionUserAgents( proto.noCompressionUserAgents);
processor.setCompressableMimeTypes( proto.compressableMimeTypes);
processor.setRestrictedUserAgents( proto.restrictedUserAgents);
processor.setSocketBuffer( proto.socketBuffer );
processor.setMaxSavePostSize( proto.maxSavePostSize );
processor.setServer( proto.server );
thData[Http11BaseProtocol.THREAD_DATA_PROCESSOR]=processor;
return thData;
}
public void processConnection(TcpConnection connection,
Object thData[]) {
Socket socket=null;
Http11Processor processor=null;
try {
processor=(Http11Processor)thData[Http11BaseProtocol.THREAD_DATA_PROCESSOR];
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
Http11BaseProtocol.log.debug
(sm.getString
("http11protocol.proto.socketexception.debug"), e);
} catch (IOException e) {
// IOExceptions are normal
Http11BaseProtocol.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.
Http11BaseProtocol.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(Http11BaseProtocol.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;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -