tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http HttpConnector.java HttpProcessor.java HttpResponseImpl.java HttpResponseStream.java
Date Thu, 09 Nov 2000 20:15:50 GMT
remm        00/11/09 12:15:50

  Modified:    catalina/src/share/org/apache/catalina/connector/http
                        HttpConnector.java HttpProcessor.java
                        HttpResponseImpl.java HttpResponseStream.java
  Log:
  - Add a switch on the connector to be able to completely disable chunking,
    if needed.
    In the server.xml file,
      <Connector className="org.apache.catalina.connector.http.HttpConnector"
                 port="80" minProcessors="5" maxProcessors="75"
                 acceptCount="10" debug="0" allowChunking="false"/>
    will create an HTTP/1.1 connector which will never attempt to chunk. If
    chunking is needed (content length is not specified), the connection will
    be closed after processing the request.
  
  Revision  Changes    Path
  1.4       +32 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java
  
  Index: HttpConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpConnector.java	2000/09/08 22:29:34	1.3
  +++ HttpConnector.java	2000/11/09 20:15:50	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
1.3 2000/09/08 22:29:34 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/09/08 22:29:34 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpConnector.java,v
1.4 2000/11/09 20:15:50 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/11/09 20:15:50 $
    *
    * ====================================================================
    *
  @@ -94,7 +94,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.3 $ $Date: 2000/09/08 22:29:34 $
  + * @version $Revision: 1.4 $ $Date: 2000/11/09 20:15:50 $
    */
   
   
  @@ -249,6 +249,12 @@
       private String threadSync = "";
   
   
  +    /**
  +     * Is chunking allowed ?
  +     */
  +    private boolean allowChunking = true;
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -270,6 +276,28 @@
       public void setAcceptCount(int count) {
   
   	this.acceptCount = count;
  +
  +    }
  +
  +
  +    /**
  +     * Get the allow chunking flag.
  +     */
  +    public boolean isChunkingAllowed() {
  +
  +        return (allowChunking);
  +
  +    }
  +
  +
  +    /**
  +     * Set the allow chunking flag.
  +     * 
  +     * @param allowChunking Allow chunking flag
  +     */
  +    public void setAllowChunking(boolean allowChunking) {
  +
  +        this.allowChunking = allowChunking;
   
       }
   
  
  
  
  1.10      +7 -5      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java
  
  Index: HttpProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HttpProcessor.java	2000/10/10 17:09:24	1.9
  +++ HttpProcessor.java	2000/11/09 20:15:50	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.9 2000/10/10 17:09:24 remm Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/10/10 17:09:24 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpProcessor.java,v
1.10 2000/11/09 20:15:50 remm Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/11/09 20:15:50 $
    *
    * ====================================================================
    *
  @@ -106,7 +106,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.9 $ $Date: 2000/10/10 17:09:24 $
  + * @version $Revision: 1.10 $ $Date: 2000/11/09 20:15:50 $
    */
   
   final class HttpProcessor
  @@ -760,7 +760,9 @@
                           // requested.
                           ackRequest(output);
                           // If the protocol is HTTP/1.1, chunking is allowed.
  -                        ((HttpResponseImpl) response).setAllowChunking(true);
  +                        if (connector.isChunkingAllowed())
  +                            ((HttpResponseImpl) response)
  +                                .setAllowChunking(true);
                       }
                   }
               } catch (EOFException e) {
  
  
  
  1.4       +4 -53     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseImpl.java
  
  Index: HttpResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpResponseImpl.java	2000/11/09 18:52:08	1.3
  +++ HttpResponseImpl.java	2000/11/09 20:15:50	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseImpl.java,v
1.3 2000/11/09 18:52:08 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/11/09 18:52:08 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseImpl.java,v
1.4 2000/11/09 20:15:50 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/11/09 20:15:50 $
    *
    * ====================================================================
    *
  @@ -78,7 +78,7 @@
    *
    * @author Craig R. McClanahan
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.3 $ $Date: 2000/11/09 18:52:08 $
  + * @version $Revision: 1.4 $ $Date: 2000/11/09 20:15:50 $
    */
   
   final class HttpResponseImpl
  @@ -222,52 +222,6 @@
   
   
       /**
  -     * Add the specified header to the specified value.
  -     *
  -     * @param name Name of the header to set
  -     * @param value Value to be set
  -     */
  -    public void addHeader(String name, String value) {
  -
  -	if (isCommitted())
  -	    return;
  -
  -	if (included)
  -	    return;	// Ignore any call from an included servlet
  -
  -        super.addHeader(name, value);
  -
  -        if (name.equals("Connection") && responseStream != null)
  -            responseStream.checkChunking(this);
  -
  -    }
  -
  -
  -
  -
  -    /**
  -     * Set the specified header to the specified value.
  -     *
  -     * @param name Name of the header to set
  -     * @param value Value to be set
  -     */
  -    public void setHeader(String name, String value) {
  -
  -	if (isCommitted())
  -	    return;
  -
  -	if (included)
  -	    return;	// Ignore any call from an included servlet
  -
  -        super.setHeader(name, value);
  -
  -        if (name.equals("Connection") && responseStream != null)
  -            responseStream.checkChunking(this);
  -
  -    }
  -
  -
  -    /**
        * Removes the specified header.
        *
        * @param name Name of the header to remove
  @@ -289,9 +243,6 @@
                       headers.remove(name);
               }
   	}
  -
  -        if (name.equals("Connection") && responseStream != null)
  -            responseStream.checkChunking(this);
   
       }
   
  
  
  
  1.4       +16 -8     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java
  
  Index: HttpResponseStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpResponseStream.java	2000/11/09 18:52:08	1.3
  +++ HttpResponseStream.java	2000/11/09 20:15:50	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
1.3 2000/11/09 18:52:08 remm Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/11/09 18:52:08 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
1.4 2000/11/09 20:15:50 remm Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/11/09 20:15:50 $
    *
    * ====================================================================
    * 
  @@ -185,14 +185,22 @@
           // change the chunking mode
           if (count != 0)
               return;
  -        this.useChunking = 
  +        // Check the basic cases in which we chunk
  +        useChunking = 
               (!response.isCommitted()
  -             && response.isChunkingAllowed()
                && response.getContentLength() == -1
                && response.getStatus() != HttpServletResponse.SC_PARTIAL_CONTENT
  -             && response.getStatus() != HttpServletResponse.SC_NOT_MODIFIED
  -             && !response.isCloseConnection());
  -        if (this.useChunking)
  +             && response.getStatus() != HttpServletResponse.SC_NOT_MODIFIED);
  +        if (!response.isChunkingAllowed() && useChunking) {
  +            // If we should chunk, but chunking is forbidden by the connector,
  +            // we close the connection
  +            response.addHeader("Connection", "close");
  +        } else {
  +            response.removeHeader("Connection", "close");
  +        }
  +        // Don't chunk is the connection will be closed
  +        useChunking = (useChunking && !response.isCloseConnection());
  +        if (useChunking)
               response.addHeader("Transfer-Encoding", "chunked");
           else
               response.removeHeader("Transfer-Encoding", "chunked");
  
  
  

Mime
View raw message