cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-10-28 Thread keith
keith   2002/10/28 11:05:43

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  This cast is sort of expensive, so avoid it if possible.
  
  Revision  ChangesPath
  1.35  +36 -20
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Http10Interceptor.java12 Apr 2002 17:44:38 -  1.34
  +++ Http10Interceptor.java28 Oct 2002 19:05:40 -  1.35
   -226,7 +226,12 
catch (IOException e) { /* ignore */ }
   }
   }
  - 
  +
  +/** Internal constants for getInfo */ 
  +private static final int GET_OTHER = 0;
  +private static final int GET_CIPHER_SUITE = 1;
  +private static final int GET_PEER_CERTIFICATE_CHAIN = 2;
  +
/**
  getInfo calls for SSL data

   -238,28 +243,39 
  // attributes hand;ed here are HTTP. If you change that
  // you MUST change the test for sslSupport==null --EKR

  -   HttpRequest httpReq;
  +   if (key != null) {
  + int infoRequested = GET_OTHER;
  + if(key.equals(javax.servlet.request.cipher_suite))
  +   infoRequested = GET_CIPHER_SUITE;
  + else if(key.equals(javax.servlet.request.X509Certificate))
  +   infoRequested = GET_PEER_CERTIFICATE_CHAIN;
  +
  + if(infoRequested != GET_OTHER) {
  +   HttpRequest httpReq;
   
  -   
  -   try {
  - httpReq=(HttpRequest)request;
  -   } catch (ClassCastException e){
  - return null;
  -   }
  +   try {
  + httpReq=(HttpRequest)request;
  +   } catch (ClassCastException e){
  + return null;
  +   }

  -   if(key!=null  httpReq!=null  httpReq.sslSupport!=null){
  -   try {
  -   if(key.equals(javax.servlet.request.cipher_suite))
  -   return httpReq.sslSupport.getCipherSuite();
  -   if(key.equals(javax.servlet.request.X509Certificate))
  -   return httpReq.sslSupport.getPeerCertificateChain();
  -   } catch (Exception e){
  -   log(Exception getting SSL attribute  + key,e,Log.WARNING);
  -   return null;
  -   }
  -   }
  +   if (httpReq!=null  httpReq.sslSupport!=null){
  + try {
  +   switch (infoRequested) {
  + case GET_CIPHER_SUITE:
  +   return httpReq.sslSupport.getCipherSuite();
  + case GET_PEER_CERTIFICATE_CHAIN:
  +   return httpReq.sslSupport.getPeerCertificateChain();
  +   }
  + } catch (Exception e){
  +   log(Exception getting SSL attribute  + key,e,Log.WARNING);
  +   return null;
  + }
  +   } // if req != null
  + } // if asking for ssl attribute
  +   } // if key != null
  return super.getInfo(ctx,request,id,key);
  - }
  + } // getInfo
   }
   
   class HttpRequest extends Request {
  
  
  

--
To unsubscribe, e-mail:   mailto:tomcat-dev-unsubscribe;jakarta.apache.org
For additional commands, e-mail: mailto:tomcat-dev-help;jakarta.apache.org




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-04-12 Thread nacho

nacho   02/04/12 10:44:38

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  * Fix: for parse host header was giving the socket port when a host header was 
present without one
  
  Revision  ChangesPath
  1.34  +7 -2  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Http10Interceptor.java8 Feb 2002 12:43:58 -   1.33
  +++ Http10Interceptor.java12 Apr 2002 17:44:38 -  1.34
  @@ -386,7 +386,11 @@
   
   protected void parseHostHeader() {
MessageBytes hH=getMimeHeaders().getValue(host);
  -serverPort = socket.getLocalPort();
  +if (sslSupport != null){
  +serverPort = 443;
  +} else {
  +serverPort = 80;
  +}   
if (hH != null) {
// XXX use MessageBytes
String hostHeader = hH.toString();
  @@ -399,8 +403,9 @@
   }catch(NumberFormatException  nfe){
   }
}else serverNameMB.setString( hostHeader);
  -return;
  +return;
}
  +serverPort = socket.getLocalPort();
if( localHost != null ) {
serverNameMB.setString( localHost );
}
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-02-08 Thread larryi

larryi  02/02/08 04:43:58

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Move delay to the proper location as suggested by Bill Barker.  Make the
  attribute a number again so the length of the delay may be specified.
  
  Revision  ChangesPath
  1.33  +15 -13
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Http10Interceptor.java5 Feb 2002 01:34:02 -   1.32
  +++ Http10Interceptor.java8 Feb 2002 12:43:58 -   1.33
  @@ -100,7 +100,7 @@
   {
   private int  timeout = 30;   // 5 minutes as in Apache HTTPD server
   private String reportedname;
  -private boolean delaySocketClose = false;
  +private int socketCloseDelay=-1;
   
   public Http10Interceptor() {
super();
  @@ -123,8 +123,8 @@
   reportedname = reportedName;
   }
   
  -public void setDelaySocketClose(boolean b) {
  -delaySocketClose=b;
  +public void setSocketCloseDelay( int d ) {
  +socketCloseDelay=d;
   }
   
   public void setProperty( String prop, String value ) {
  @@ -175,6 +175,18 @@

cm.service( reqA, resA );
   
  +// 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( socketCloseDelay = 0 ) {
  +try {
  +Thread.sleep(socketCloseDelay);
  +} catch (InterruptedException ie) { /* ignore */ }
  +}
  +
   // XXX didn't honor HTTP/1.0 KeepAlive, should be fixed
TcpConnection.shutdownInput( socket );
}
  @@ -208,16 +220,6 @@
log( Error reading request, ignored, e, Log.ERROR);
} 
finally {
  -// When running tests against Tomcat on the same
  -// system, we may need to force a thread switch
  -// before closing the socket to give the other
  -// end of the connection a chance to run
  -if( delaySocketClose ) {
  -try {
  -Thread.sleep(0);
  -} catch (InterruptedException ie) { /* ignore */ }
  -}
  -
// recycle kernel sockets ASAP
   // XXX didn't honor HTTP/1.0 KeepAlive, should be fixed
try { if (socket != null) socket.close (); }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-02-04 Thread larryi

larryi  02/02/04 17:34:02

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Revert back to the delaySocketClose attribute.  The new code turned out
  not to help.
  
  Revision  ChangesPath
  1.32  +11 -17
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Http10Interceptor.java31 Jan 2002 04:16:47 -  1.31
  +++ Http10Interceptor.java5 Feb 2002 01:34:02 -   1.32
  @@ -100,7 +100,7 @@
   {
   private int  timeout = 30;   // 5 minutes as in Apache HTTPD server
   private String reportedname;
  -private int socketCloseDelay = -1;
  +private boolean delaySocketClose = false;
   
   public Http10Interceptor() {
super();
  @@ -123,8 +123,8 @@
   reportedname = reportedName;
   }
   
  -public void setSocketCloseDelay(int d) {
  -socketCloseDelay=d;
  +public void setDelaySocketClose(boolean b) {
  +delaySocketClose=b;
   }
   
   public void setProperty( String prop, String value ) {
  @@ -208,20 +208,14 @@
log( Error reading request, ignored, e, Log.ERROR);
} 
finally {
  -// When running tests against Tomcat on the same system,
  -// we may need to add a delay before closing the socket
  -// to give the other end of the connection a chance to run
  -if( socketCloseDelay = 0 ) {
  -if( socketCloseDelay  0 ) {
  -// if delay is specified, spin for that amount of time
  -// Note: using Thread.sleep(n) exacerbates the problem on
  -// RH Linux 7.1 and maybe others
  -long target = System.currentTimeMillis() + socketCloseDelay;
  -while( target = System.currentTimeMillis())
  -;
  -} else {
  -Thread.yield();
  -}
  +// When running tests against Tomcat on the same
  +// system, we may need to force a thread switch
  +// before closing the socket to give the other
  +// end of the connection a chance to run
  +if( delaySocketClose ) {
  +try {
  +Thread.sleep(0);
  +} catch (InterruptedException ie) { /* ignore */ }
   }
   
// recycle kernel sockets ASAP
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-01-30 Thread larryi

larryi  02/01/30 20:16:47

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Reworking the delay kluge for test software in which client and server run
  on the same system and experience Socket reset by peer errors due to
  unfavorable sequencing of thread execution.  This update was needed
  because adding the sleep(0) caused the failure rate of Tomcat 3.3 tests
  under Cactus to go from infrequently to frequently on the primary Gump
  system running Linux.
  
  Changed delaySocketClose to closeSocketDelay and made the attribute
  numeric.  The default is -1, which adds no delay.  A value of 0, adds a
  Thread.yield() prior to closing the socket.  A value greater than 1 causes
  CPU cycles to be eaten for the specified number of milliseconds prior to
  closing the socket.  Using Thread.sleep(n) proved to be unhelpful on
  RH Linux 7.1.
  
  Revision  ChangesPath
  1.31  +17 -11
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Http10Interceptor.java25 Jan 2002 04:09:10 -  1.30
  +++ Http10Interceptor.java31 Jan 2002 04:16:47 -  1.31
  @@ -100,7 +100,7 @@
   {
   private int  timeout = 30;   // 5 minutes as in Apache HTTPD server
   private String reportedname;
  -private boolean delaySocketClose = false;
  +private int socketCloseDelay = -1;
   
   public Http10Interceptor() {
super();
  @@ -123,8 +123,8 @@
   reportedname = reportedName;
   }
   
  -public void setDelaySocketClose(boolean b) {
  -delaySocketClose=b;
  +public void setSocketCloseDelay(int d) {
  +socketCloseDelay=d;
   }
   
   public void setProperty( String prop, String value ) {
  @@ -208,14 +208,20 @@
log( Error reading request, ignored, e, Log.ERROR);
} 
finally {
  -// When running tests against Tomcat on the same
  -// system, we may need to force a thread switch
  -// before closing the socket to give the other
  -// end of the connection a chance to run
  -if( delaySocketClose ) {
  -try {
  -Thread.sleep(0);
  -} catch (InterruptedException ie) { /* ignore */ }
  +// When running tests against Tomcat on the same system,
  +// we may need to add a delay before closing the socket
  +// to give the other end of the connection a chance to run
  +if( socketCloseDelay = 0 ) {
  +if( socketCloseDelay  0 ) {
  +// if delay is specified, spin for that amount of time
  +// Note: using Thread.sleep(n) exacerbates the problem on
  +// RH Linux 7.1 and maybe others
  +long target = System.currentTimeMillis() + socketCloseDelay;
  +while( target = System.currentTimeMillis())
  +;
  +} else {
  +Thread.yield();
  +}
   }
   
// recycle kernel sockets ASAP
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-01-24 Thread larryi

larryi  02/01/24 20:09:10

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Add a setProperty method so attributes without a predefined setter will
  still be stored as attributes and made available to the socket factory.
  Now attributes such as keystoreType and the new keystorePass can be
  specified.  PureTLS unique attributes, such as rootfile, can be specified
  as well.
  
  Revision  ChangesPath
  1.30  +4 -0  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Http10Interceptor.java8 Jan 2002 00:48:19 -   1.29
  +++ Http10Interceptor.java25 Jan 2002 04:09:10 -  1.30
  @@ -127,6 +127,10 @@
   delaySocketClose=b;
   }
   
  +public void setProperty( String prop, String value ) {
  +setAttribute( prop, value );
  +}
  +
   //  Handler implementation 
   public void setServer( Object o ) {
this.cm=(ContextManager)o;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2002-01-07 Thread larryi

larryi  02/01/07 16:48:20

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Added a delaySocketClose attribute that when true, executes a
  Thread.sleep(0)  to force a thread switch just prior to closing the socket.
  This was needed by Cactus to avoid Socket reset by peer errors on a
  high powered Windows XP system.
  
  Also added an setSoLinger(100) to help ensure the output is delivered.
  
  Revision  ChangesPath
  1.29  +17 -0 
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Http10Interceptor.java7 Dec 2001 04:38:26 -   1.28
  +++ Http10Interceptor.java8 Jan 2002 00:48:19 -   1.29
  @@ -100,9 +100,11 @@
   {
   private int  timeout = 30;   // 5 minutes as in Apache HTTPD server
   private String reportedname;
  +private boolean delaySocketClose = false;
   
   public Http10Interceptor() {
super();
  +super.setSoLinger( 100 );
// defaults:
this.setPort( 8080 );
   }
  @@ -120,6 +122,11 @@
   public void setReportedname( String reportedName) {
   reportedname = reportedName;
   }
  +
  +public void setDelaySocketClose(boolean b) {
  +delaySocketClose=b;
  +}
  +
   //  Handler implementation 
   public void setServer( Object o ) {
this.cm=(ContextManager)o;
  @@ -197,6 +204,16 @@
log( Error reading request, ignored, e, Log.ERROR);
} 
finally {
  +// When running tests against Tomcat on the same
  +// system, we may need to force a thread switch
  +// before closing the socket to give the other
  +// end of the connection a chance to run
  +if( delaySocketClose ) {
  +try {
  +Thread.sleep(0);
  +} catch (InterruptedException ie) { /* ignore */ }
  +}
  +
// recycle kernel sockets ASAP
   // XXX didn't honor HTTP/1.0 KeepAlive, should be fixed
try { if (socket != null) socket.close (); }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java PoolTcpConnector.java

2001-12-06 Thread billbarker

billbarker01/12/06 20:38:26

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java PoolTcpConnector.java
  Log:
  PureTLS support changes.
  Submitted by: Eric Rescorla [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.28  +45 -7 
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Http10Interceptor.java2001/11/02 03:14:03 1.27
  +++ Http10Interceptor.java2001/12/07 04:38:26 1.28
  @@ -156,6 +156,10 @@
reqA.readNextRequest(resA);
if( secure ) {
reqA.scheme().setString( https );
  + 
  + // Load up the SSLSupport class
  + if(sslImplementation != null)
  + reqA.setSSLSupport(sslImplementation.getSSLSupport(socket));
}

cm.service( reqA, resA );
  @@ -199,13 +203,47 @@
catch (IOException e) { /* ignore */ }
   }
   }
  + 
  + /**
  +   getInfo calls for SSL data
  + 
  +   @return the requested data
  + */
  + public Object getInfo( Context ctx, Request request,
  +int id, String key ) {
  +   // The following code explicitly assumes that the only
  +   // attributes hand;ed here are HTTP. If you change that
  +   // you MUST change the test for sslSupport==null --EKR
  + 
  +   HttpRequest httpReq;
  +
  +   
  +   try {
  + httpReq=(HttpRequest)request;
  +   } catch (ClassCastException e){
  + return null;
  +   }
  + 
  +   if(key!=null  httpReq!=null  httpReq.sslSupport!=null){
  +   try {
  +   if(key.equals(javax.servlet.request.cipher_suite))
  +   return httpReq.sslSupport.getCipherSuite();
  +   if(key.equals(javax.servlet.request.X509Certificate))
  +   return httpReq.sslSupport.getPeerCertificateChain();
  +   } catch (Exception e){
  +   log(Exception getting SSL attribute  + key,e,Log.WARNING);
  +   return null;
  +   }
  +   }
  +   return super.getInfo(ctx,request,id,key);
  + }
   }
   
   class HttpRequest extends Request {
   Http10 http=new Http10();
   private boolean moreRequests = false;
   Socket socket;
  -static CertCompat certcompat = CertCompat.getCertCompat();
  +SSLSupport sslSupport=null;
   
   public HttpRequest() {
   super();
  @@ -214,12 +252,6 @@
   remoteAddrMB.recycle();
   remoteHostMB.recycle();
   }
  -public Object getAttribute(String name) {
  -if (name.equals(javax.servlet.request.X509Certificate)) {
  -return(certcompat.getX509Certificates(socket));
  - }
  -return(super.getAttribute(name));
  -}
   
   public void recycle() {
super.recycle();
  @@ -227,6 +259,7 @@
   // recycle these to remove the defaults
   remoteAddrMB.recycle();
   remoteHostMB.recycle();
  + sslSupport=null;
   }
   
   public void setSocket(Socket socket) throws IOException {
  @@ -352,6 +385,11 @@
//  log(No server name, defaulting to localhost);
   serverNameMB.setString( getLocalHost() );
   }
  + 
  +void setSSLSupport(SSLSupport s){
  +sslSupport=s;
  +}
  + 
   }
   
   
  
  
  
  1.13  +29 -27
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/PoolTcpConnector.java
  
  Index: PoolTcpConnector.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/PoolTcpConnector.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PoolTcpConnector.java 2001/11/07 03:36:47 1.12
  +++ PoolTcpConnector.java 2001/12/07 04:38:26 1.13
  @@ -88,9 +88,11 @@
   {
   protected PoolTcpEndpoint ep;
   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;
   protected boolean secure=false;
   
   public PoolTcpConnector() {
  @@ -187,33 +189,39 @@
*/
   private void checkSocketFactory() throws TomcatException {
if(secure) {
  - if(socketFactoryName == null)
  - socketFactoryName = SSL_FACT;
  - /* backwards compatibility */
  - if(SSL_FACT.equals(socketFactoryName)) {
  - try {
  - Class 

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-11-01 Thread billbarker

billbarker01/11/01 19:14:03

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Fix recycling the remoteAddr and remoteHost.
  
  The remoteAddr and remoteHost would get reset to the default localhost values after 
recycling.
  
  Fix for bug 4564
  Reported by: Alessandro Polverini [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.27  +3 -0  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Http10Interceptor.java2001/10/03 22:13:45 1.26
  +++ Http10Interceptor.java2001/11/02 03:14:03 1.27
  @@ -224,6 +224,9 @@
   public void recycle() {
super.recycle();
if( http!=null) http.recycle();
  +// recycle these to remove the defaults
  +remoteAddrMB.recycle();
  +remoteHostMB.recycle();
   }
   
   public void setSocket(Socket socket) throws IOException {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-10-03 Thread mmanders

mmanders01/10/03 15:13:45

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Fix Bug #3944 request.getRemoteAddr() alays returning 127.0.0.1
  Bug report from Alessandro Polverini
  
  Since the base Request object set remoteAddr and remoteHost to defaults,
  the checks around setting them off of the real request always succeed so the
  real values are never used.  Added calls to recycle these in the constructor.
  This still allows for delayed setting, since the calls to set the values can be
  expensive.
  
  Revision  ChangesPath
  1.26  +4 -0  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Http10Interceptor.java2001/09/22 22:05:31 1.25
  +++ Http10Interceptor.java2001/10/03 22:13:45 1.26
  @@ -209,6 +209,10 @@
   
   public HttpRequest() {
   super();
  +
  +// recycle these to remove the defaults
  +remoteAddrMB.recycle();
  +remoteHostMB.recycle();
   }
   public Object getAttribute(String name) {
   if (name.equals(javax.servlet.request.X509Certificate)) {
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-09-22 Thread costin

costin  01/09/22 15:05:31

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Fix for 3745 - thanks Stefan Eissing for finding the bug.
  
  doRead() should return -1 on end of stream, and available should be used
  only if is known ( -1 means unknown length, read until EOF ).
  
  Revision  ChangesPath
  1.25  +14 -5 
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Http10Interceptor.java2001/09/21 08:29:56 1.24
  +++ Http10Interceptor.java2001/09/22 22:05:31 1.25
  @@ -232,17 +232,26 @@
   }
   
   public int doRead() throws IOException {
  - if( available = 0 )
  + if( available == 0 ) 
return -1;
  - available--;
  + // #3745
  + // if available == -1: unknown length, we'll read until end of stream.
  + if( available!= -1 )
  + available--;
return http.doRead();
   }
   
   public int doRead(byte[] b, int off, int len) throws IOException {
  - if( available = 0 )
  - return 0;
  + if( available == 0 )
  + return -1;
  + // if available == -1: unknown length, we'll read until end of stream.
int rd=http.doRead( b, off, len );
  - available -= rd;
  + if( rd==-1) {
  + available=0;
  + return -1;
  + }
  + if( available!= -1 )
  + available -= rd;
return rd;
   }
   
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-09-01 Thread larryi

larryi  01/09/01 06:03:06

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Fix NPE where for certain invalid requests the context isn't set.
  
  Revision  ChangesPath
  1.22  +8 -4  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Http10Interceptor.java2001/08/31 09:45:50 1.21
  +++ Http10Interceptor.java2001/09/01 13:03:06 1.22
  @@ -366,13 +366,17 @@
   }
   
   // return server name (or the reported one)
  -if (reportedname == null)
  -getMimeHeaders().setValue(  Server 
).setString(request.getContext().getEngineHeader());
  -else
  +if (reportedname == null) {
  +Context ctx = request.getContext();
  +String server = ctx != null ? ctx.getEngineHeader() : 
  +ContextManager.TOMCAT_NAME + / + ContextManager.TOMCAT_VERSION;   
 
  +getMimeHeaders().setValue(  Server ).setString(server);
  +} else {
   if (reportedname.length() != 0)
   getMimeHeaders().setValue(  Server ).setString(reportedname);
  +}
   
  - http.sendHeaders( getMimeHeaders() );
  +http.sendHeaders( getMimeHeaders() );
   }
   
   public void doWrite( byte buffer[], int pos, int count)
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-07-27 Thread costin

costin  01/07/27 20:09:55

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Small improvement - delayed eveluation.
  
  Revision  ChangesPath
  1.19  +12 -7 
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Http10Interceptor.java2001/07/26 11:14:11 1.18
  +++ Http10Interceptor.java2001/07/28 03:09:55 1.19
  @@ -242,8 +242,6 @@
return;
}
   
  -this.remoteAddr().setString(socket.getInetAddress().getHostAddress());
  -
// for 0.9, we don't have headers!
if (! protoMB.equals()) {
// all HTTP versions with protocol also have headers
  @@ -261,14 +259,21 @@
   }
   
   //  override special methods
  -
   
  -public String getRemoteAddr() {
  -return socket.getInetAddress().getHostAddress();
  +public MessageBytes remoteAddr() {
  + // WARNING: On some linux configurations, this call may get you in
  + // trubles... Big trubles...
  + if( remoteAddrMB.isNull() ) {
  + remoteAddrMB.setString(socket.getInetAddress().getHostAddress());
  + }
  + return remoteAddrMB;
   }
   
  -public String getRemoteHost() {
  - return socket.getInetAddress().getHostName();
  +public MessageBytes remoteHost() {
  + if( remoteHostMB.isNull() ) {
  + remoteHostMB.setString( socket.getInetAddress().getHostName() );
  + }
  + return remoteHostMB;
   }
   
   public String getLocalHost() {
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-07-26 Thread hgomez

hgomez  01/07/26 04:14:11

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Correct getRemoteAddr() bug in native http 1.0 connector
  Bug report from Clayton Vernon
  
  Revision  ChangesPath
  1.18  +2 -0  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Http10Interceptor.java2001/06/28 07:29:08 1.17
  +++ Http10Interceptor.java2001/07/26 11:14:11 1.18
  @@ -242,6 +242,8 @@
return;
}
   
  +this.remoteAddr().setString(socket.getInetAddress().getHostAddress());
  +
// for 0.9, we don't have headers!
if (! protoMB.equals()) {
// all HTTP versions with protocol also have headers
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-06-28 Thread costin

costin  01/06/28 00:29:11

  Modified:src/share/org/apache/tomcat/modules/config
LoaderInterceptor11.java LogSetter.java
   src/share/org/apache/tomcat/modules/loggers LogEvents.java
   src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Small changes to make the code match the defaults in server.xml ( and
  so EmebededTomcat to behave more closely to main tomcat ).
  
  This should also make it easier to implement the minimal tomcat.
  
  Revision  ChangesPath
  1.13  +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LoaderInterceptor11.java
  
  Index: LoaderInterceptor11.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LoaderInterceptor11.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LoaderInterceptor11.java  2001/06/17 18:09:15 1.12
  +++ LoaderInterceptor11.java  2001/06/28 07:28:51 1.13
  @@ -78,7 +78,7 @@
* @author [EMAIL PROTECTED]
*/
   public class LoaderInterceptor11 extends BaseInterceptor {
  -boolean useAL=false;
  +boolean useAL=true;
   boolean useNoParent=false;
   private int attributeInfo;
   
  
  
  
  1.12  +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LogSetter.java
  
  Index: LogSetter.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/LogSetter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LogSetter.java2001/04/21 18:23:54 1.11
  +++ LogSetter.java2001/06/28 07:28:54 1.12
  @@ -139,7 +139,7 @@
   public class LogSetter extends  BaseInterceptor {
   String name;
   String path;
  -String verbosityLevel;
  +String verbosityLevel=INFORMATION;
   boolean servletLogger=false;
   boolean timestamps=true;
   String tsFormat=null;
  
  
  
  1.4   +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/loggers/LogEvents.java
  
  Index: LogEvents.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/loggers/LogEvents.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LogEvents.java2001/02/11 02:26:24 1.3
  +++ LogEvents.java2001/06/28 07:29:03 1.4
  @@ -87,7 +87,7 @@
 + enabled);
hooks.addModule( this );
}
  - return DECLINED;
  + return OK;
   }
   
   //  Request notifications 
  
  
  
  1.17  +4 -2  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Http10Interceptor.java2001/03/22 09:58:28 1.16
  +++ Http10Interceptor.java2001/06/28 07:29:08 1.17
  @@ -94,10 +94,12 @@
   public class Http10Interceptor extends PoolTcpConnector
   implements  TcpConnectionHandler
   {
  - private int timeout = 30;   // 5 minutes as in Apache HTTPD server
  +private int  timeout = 30;   // 5 minutes as in Apache HTTPD server
   
   public Http10Interceptor() {
super();
  + // defaults:
  + this.setPort( 8080 );
   }
   
   //  PoolTcpConnector 
  @@ -108,7 +110,7 @@
   
   //  Attributes 
   public void setTimeout( int timeouts ) {
  -timeout = timeouts * 1000;
  + timeout = timeouts * 1000;
   }
   
   //  Handler implementation 
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2001-03-22 Thread hgomez

hgomez  01/03/22 01:58:29

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Fix BUG #1006, by adding socket timeout
  Default is 300s (5mn) but you could configure it in server.xml
  timeout attribute (in second).
  
  Revision  ChangesPath
  1.16  +14 -0 
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Http10Interceptor.java2001/03/02 04:49:25 1.15
  +++ Http10Interceptor.java2001/03/22 09:58:28 1.16
  @@ -94,6 +94,8 @@
   public class Http10Interceptor extends PoolTcpConnector
   implements  TcpConnectionHandler
   {
  + private int timeout = 30;   // 5 minutes as in Apache HTTPD server
  +
   public Http10Interceptor() {
super();
   }
  @@ -105,6 +107,10 @@
   }
   
   //  Attributes 
  +public void setTimeout( int timeouts ) {
  +timeout = timeouts * 1000;
  +}
  +
   //  Handler implementation 
   public void setServer( Object o ) {
this.cm=(ContextManager)o;
  @@ -131,6 +137,7 @@
resA=(HttpResponse)thData[1];
   
socket=connection.getSocket();
  + socket.setSoTimeout(timeout);
   
reqA.setSocket( socket );
resA.setSocket( socket );
  @@ -149,6 +156,13 @@
log( "SocketException reading request, ignored", null,
 Log.INFORMATION);
log( "SocketException reading request:", e, Log.DEBUG);
  + }
  + catch (java.io.InterruptedIOException ioe) {
  + // We have armed a timeout on read as does apache httpd server.
  + // Just to avoid staying with inactive connection
  + // BUG#1006
  + ioe.printStackTrace();
  + log( "Timeout reading request, aborting", ioe, Log.ERROR);
}
catch (java.io.IOException e) {
// IOExceptions are normal 
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2000-12-16 Thread nacho

nacho   00/12/16 18:37:35

  Modified:src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Bug setting servername when port is 80
  
  Revision  ChangesPath
  1.9   +2 -2  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java
  
  Index: Http10Interceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10Interceptor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Http10Interceptor.java2000/12/03 08:19:03 1.8
  +++ Http10Interceptor.java2000/12/17 02:37:35 1.9
  @@ -277,8 +277,8 @@
   serverPort=Integer.parseInt(hostHeader);
   }catch(NumberFormatException  nfe){
   }
  - }
  -return;
  + }else serverNameMB.setString( hostHeader);
  +return;
}
if( localHost != null ) {
serverNameMB.setString( localHost );
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/server Http10Interceptor.java

2000-12-03 Thread costin

costin  00/12/03 00:19:03

  Modified:src/share/org/apache/tomcat/context ErrorHandler.java
   src/share/org/apache/tomcat/core BaseInterceptor.java
ContextManager.java
   src/share/org/apache/tomcat/modules/server
Http10Interceptor.java
  Log:
  Few more changes in startup:
  
  - make sure no request is served before all interceptors are started.
  
  - added 2 more hooks - engineStart/engineStop. That will allow modules
  to know when the engine is accepting connections and when is it stopped
  ( mostly for the use of connectors )
  
  Revision  ChangesPath
  1.7   +2 -1  
jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java
  
  Index: ErrorHandler.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/ErrorHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ErrorHandler.java 2000/11/30 04:58:39 1.6
  +++ ErrorHandler.java 2000/12/03 08:19:02 1.7
  @@ -144,9 +144,10 @@
// error
// XXX this log was intended to debug the status code generation.
// it can be removed for all cases.
  - if( code != 302  code != 401  code!=400  ) // tuneme
  + if( code != 302  code != 401  code!=400  ) {// tuneme
ctx.log( "Status code:" + code + " request:"  + req + " msg:" +
 req.getAttribute("javax.servlet.error.message"));
  + }

errorPath = ctx.getErrorPage( code );
if( errorPath != null ) {
  
  
  
  1.27  +15 -0 
jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- BaseInterceptor.java  2000/12/02 08:26:45 1.26
  +++ BaseInterceptor.java  2000/12/03 08:19:02 1.27
  @@ -326,6 +326,21 @@
   {
   }
   
  +/** This notifies that tomcat is started. Adapters shouldn't
  + accept connections before everything is set up internally.
  +*/
  +public void engineStart(ContextManager cm )
  + throws TomcatException
  +{
  +}
  +
  +/** This notifies that tomcat is stoped. No more requests will
  + be processed.
  +*/
  +public void engineStop(ContextManager cm )
  + throws TomcatException
  +{
  +}
   
   /**
*  Called when a context is added to a CM. The context is probably not
  
  
  
  1.154 +39 -10
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.153
  retrieving revision 1.154
  diff -u -r1.153 -r1.154
  --- ContextManager.java   2000/12/02 08:26:47 1.153
  +++ ContextManager.java   2000/12/03 08:19:03 1.154
  @@ -425,21 +425,13 @@
cI[i].addContext( this, ctx );
}
ctx.setState( Context.STATE_ADDED );
  + log("Adding " +  ctx.toString());
} catch( TomcatException ex ) {
log( "Context not added " + ctx , ex );
continue;
}
}
  -}
   
  -/** Will start the connectors and begin serving requests.
  - *  It must be called after init.
  - */
  -public final void start() throws TomcatException {
  - if( state!=STATE_INIT )
  - throw new TomcatException( "Invalid state in start(), " +
  -" you need to call init() "+ state);
  - 
Enumeration enum = getContexts();
while (enum.hasMoreElements()) {
Context ctx = (Context)enum.nextElement();
  @@ -453,6 +445,24 @@
}
}
   
  +
  +}
  +
  +/** Will start the connectors and begin serving requests.
  + *  It must be called after init.
  + */
  +public final void start() throws TomcatException {
  + if( state!=STATE_INIT )
  + throw new TomcatException( "Invalid state in start(), " +
  +" you need to call init() "+ state);
  + 
  + //XXX before or after state=START ?
  + 
  + BaseInterceptor cI[]=defaultContainer.getInterceptors();
  + for( int i=0; i cI.length; i++ ) {
  + cI[i].engineStart( this );
  + }
  +
// requests can be processed now
state=STATE_START;
   }
  @@ -460,6 +470,14 @@
   /** Will stop all connectors
*/
   public final void stop() throws Exception {
  + state=STATE_INIT; // initialized, but not accepting