remm        01/10/04 12:26:29

  Modified:    catalina/src/share/org/apache/catalina/connector/http Tag:
                        tomcat_40_branch HttpResponseStream.java
  Log:
  - Merge a variety of fixes and small feature additions which have been made
    and debugged in the HEAD branch, including:
    - Removal of Jasper loader (merged with the shared loader).
    - Fixes a lot of spec complaince issue regarding the commit state of the
      response when using forwards, sendError or sendRedirect.
    - Fixes cache consistency issues for static resource serving.
    - Adds content caching for static resources (that's linked to the bugfix
      mentioned just above).
    - Merge enhanced error reporting and error page dispatching (which will be
      able to display error pages for most errors returned from the pipeline -
      like the 401 and 403 returned by the authenticator).
    - Merge the fixes for all the other more recent bugfixes that have been
      fixed in the HEAD branch.
    - Passes all tester and Watchdog tests.
    - Merge a variety of small enhancements to the build scripts which have been
      made in the HEAD branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.1   +38 -15    
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.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- HttpResponseStream.java   2001/07/22 20:25:07     1.7
  +++ HttpResponseStream.java   2001/10/04 19:26:29     1.7.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
 1.7 2001/07/22 20:25:07 pier Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/07/22 20:25:07 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/connector/http/HttpResponseStream.java,v
 1.7.2.1 2001/10/04 19:26:29 remm Exp $
  + * $Revision: 1.7.2.1 $
  + * $Date: 2001/10/04 19:26:29 $
    *
    * ====================================================================
    *
  @@ -131,15 +131,23 @@
        */
       public void write(int b)
           throws IOException {
  +
  +        if (suspended)
  +            return;
  +
           if (useChunking && !writingChunk) {
               writingChunk = true;
  -            print("1\r\n");
  -            super.write(b);
  -            println();
  -            writingChunk = false;
  +            try {
  +                print("1\r\n");
  +                super.write(b);
  +                println();
  +            } finally {
  +                writingChunk = false;
  +            }
           } else {
               super.write(b);
           }
  +
       }
   
   
  @@ -148,17 +156,25 @@
        */
       public void write(byte[] b, int off, int len)
           throws IOException {
  +
  +        if (suspended)
  +            return;
  +
           if (useChunking && !writingChunk) {
               if (len > 0) {
                   writingChunk = true;
  -                println(Integer.toHexString(len));
  -                super.write(b, off, len);
  -                println();
  -                writingChunk = false;
  +                try {
  +                    println(Integer.toHexString(len));
  +                    super.write(b, off, len);
  +                    println();
  +                } finally {
  +                    writingChunk = false;
  +                }
               }
           } else {
               super.write(b, off, len);
           }
  +
       }
   
   
  @@ -168,11 +184,18 @@
        */
       public void close() throws IOException {
   
  +        if (suspended)
  +            throw new IOException
  +                (sm.getString("responseStream.suspended"));
  +
           if (useChunking) {
               // Write the final chunk.
               writingChunk = true;
  -            print("0\r\n\r\n");
  -            writingChunk = false;
  +            try {
  +                print("0\r\n\r\n");
  +            } finally {
  +                writingChunk = false;
  +            }
           }
           super.close();
   
  @@ -195,14 +218,14 @@
           if (!response.isChunkingAllowed() && useChunking) {
               // If we should chunk, but chunking is forbidden by the connector,
               // we close the connection
  -            response.addHeader("Connection", "close");
  +            response.setHeader("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");
  +            response.setHeader("Transfer-Encoding", "chunked");
           else
               response.removeHeader("Transfer-Encoding", "chunked");
       }
  
  
  


Reply via email to