You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2004/10/02 01:36:15 UTC

cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11 InternalOutputBuffer.java Constants.java Http11Processor.java

remm        2004/10/01 16:36:15

  Modified:    http11/src/java/org/apache/coyote/http11
                        InternalOutputBuffer.java Constants.java
                        Http11Processor.java
  Log:
  - Fix a oops with my usage of "constant" bytes arrays. So, ok, I can't do that.
  - Use a byte array for server.
  
  Revision  Changes    Path
  1.24      +1 -1      jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java
  
  Index: InternalOutputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalOutputBuffer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- InternalOutputBuffer.java	31 Aug 2004 23:52:51 -0000	1.23
  +++ InternalOutputBuffer.java	1 Oct 2004 23:36:15 -0000	1.24
  @@ -682,7 +682,7 @@
        * 
        * @param b data to be written
        */
  -    protected void write(byte[] b) {
  +    public void write(byte[] b) {
   
           // Writing the byte chunk to the output buffer
           System.arraycopy(b, 0, buf, pos, b.length);
  
  
  
  1.24      +12 -10    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Constants.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Constants.java	29 Sep 2004 09:54:28 -0000	1.23
  +++ Constants.java	1 Oct 2004 23:36:15 -0000	1.24
  @@ -41,9 +41,15 @@
       
       
       /**
  +     * CRLF.
  +     */
  +    public static final String CRLF = "\r\n";
  +
  +    
  +    /**
        * Server string.
        */
  -    public static final byte[] SERVER_BYTES = convertToBytes("Apache-Coyote/1.1");
  +    public static final byte[] SERVER_BYTES = convertToBytes("Server: Apache-Coyote/1.1" + CRLF);
   
       
       /**
  @@ -112,21 +118,17 @@
       public static final int DEFAULT_HTTP_HEADER_BUFFER_SIZE = 48 * 1024;
   
   
  -    /**
  -     * CRLF.
  -     */
  -    public static final String CRLF = "\r\n";
  -
  -    
       /* Various constant "strings" */
       public static final byte[] CRLF_BYTES = convertToBytes(CRLF);
       public static final byte[] COLON_BYTES = convertToBytes(": ");
  -    public static final byte[] CONNECTION_BYTES = convertToBytes("Connection");
  +    public static final String CONNECTION = "Connection";
  +    public static final String CLOSE = "close";
       public static final byte[] CLOSE_BYTES = convertToBytes("close");
  +    public static final String KEEPALIVE = "keep-alive";
       public static final byte[] KEEPALIVE_BYTES = convertToBytes("keep-alive");
  -    public static final byte[] CHUNKED_BYTES = convertToBytes("chunked");
  +    public static final String CHUNKED = "chunked";
       public static final byte[] ACK_BYTES = convertToBytes("HTTP/1.1 100 Continue" + CRLF + CRLF);
  -    public static final byte[] TRANSFERENCODING_BYTES = convertToBytes("Transfer-Encoding");
  +    public static final String TRANSFERENCODING = "Transfer-Encoding";
       
   
       /**
  
  
  
  1.112     +10 -15    jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
  
  Index: Http11Processor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- Http11Processor.java	29 Sep 2004 09:54:28 -0000	1.111
  +++ Http11Processor.java	1 Oct 2004 23:36:15 -0000	1.112
  @@ -1500,9 +1500,7 @@
                   outputBuffer.addActiveFilter
                       (outputFilters[Constants.CHUNKED_FILTER]);
                   contentDelimitation = true;
  -                headers.addValue(Constants.TRANSFERENCODING_BYTES, 
  -                        0, Constants.TRANSFERENCODING_BYTES.length).setBytes
  -                    (Constants.CHUNKED_BYTES, 0, Constants.CHUNKED_BYTES.length);
  +                headers.addValue(Constants.TRANSFERENCODING).setString(Constants.CHUNKED);
               } else {
                   outputBuffer.addActiveFilter
                       (outputFilters[Constants.IDENTITY_FILTER]);
  @@ -1531,14 +1529,6 @@
           }
           headers.setValue("Date").setString(date);
   
  -        // Add server header
  -        if (server != null) {
  -            headers.setValue("Server").setString(server);
  -        } else {
  -            headers.setValue("Server").setBytes(Constants.SERVER_BYTES, 
  -                    0, Constants.SERVER_BYTES.length);
  -        }
  -
           // FIXME: Add transfer encoding header
   
           if ((entityBody) && (!contentDelimitation)) {
  @@ -1551,15 +1541,20 @@
           // Connection: close header.
           keepAlive = keepAlive && !statusDropsConnection(statusCode);
           if (!keepAlive) {
  -            headers.addValue(Constants.CONNECTION_BYTES, 0, Constants.CONNECTION_BYTES.length)
  -                .setBytes(Constants.CLOSE_BYTES, 0, Constants.CLOSE_BYTES.length);
  +            headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
           } else if (!http11) {
  -            headers.addValue(Constants.CONNECTION_BYTES, 0, Constants.CONNECTION_BYTES.length)
  -                .setBytes(Constants.KEEPALIVE_BYTES, 0, Constants.KEEPALIVE_BYTES.length);
  +            headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
           }
   
           // Build the response header
           outputBuffer.sendStatus();
  +
  +        // Add server header
  +        if (server != null) {
  +            headers.setValue("Server").setString(server);
  +        } else {
  +            outputBuffer.write(Constants.SERVER_BYTES);
  +        }
   
           int size = headers.size();
           for (int i = 0; i < size; i++) {
  
  
  

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