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 2003/09/15 16:16:17 UTC

cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4 OutputBuffer.java

remm        2003/09/15 07:16:17

  Modified:    coyote/src/java/org/apache/coyote/tomcat4 OutputBuffer.java
  Log:
  - Untested port of the changes to the flush behavior in HTTP.
  
  Revision  Changes    Path
  1.10      +28 -4     jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/OutputBuffer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- OutputBuffer.java	11 Nov 2002 11:01:04 -0000	1.9
  +++ OutputBuffer.java	15 Sep 2003 14:16:17 -0000	1.10
  @@ -66,12 +66,13 @@
   import java.io.Writer;
   import java.util.Hashtable;
   
  +import org.apache.catalina.connector.ClientAbortException;
  +import org.apache.coyote.ActionCode;
  +import org.apache.coyote.Response;
   import org.apache.tomcat.util.buf.ByteChunk;
   import org.apache.tomcat.util.buf.C2BConverter;
   import org.apache.tomcat.util.buf.CharChunk;
   
  -import org.apache.coyote.Response;
  -
   
   /**
    * The buffer used by Tomcat response. This is a derivative of the Tomcat 3.3
  @@ -320,7 +321,7 @@
               }
           }
   
  -        flush();
  +        doFlush(false);
           closed = true;
   
           coyoteResponse.finish();
  @@ -335,6 +336,17 @@
        */
       public void flush()
           throws IOException {
  +        doFlush(true);
  +    }
  +
  +
  +    /**
  +     * Flush bytes or chars contained in the buffer.
  +     * 
  +     * @throws IOException An underlying IOException occurred
  +     */
  +    protected void doFlush(boolean realFlush)
  +        throws IOException {
   
           if (suspended)
               return;
  @@ -350,6 +362,11 @@
               realWriteBytes(null, 0, 0);       // nothing written yet
           doFlush = false;
   
  +        if (realFlush) {
  +            coyoteResponse.action(ActionCode.ACTION_CLIENT_FLUSH, 
  +                                  coyoteResponse);
  +        }
  +
       }
   
   
  @@ -381,7 +398,14 @@
           if (cnt > 0) {
               // real write to the adapter
               outputChunk.setBytes(buf, off, cnt);
  -            coyoteResponse.doWrite(outputChunk);
  +            try {
  +                coyoteResponse.doWrite(outputChunk);
  +            } catch (IOException e) {
  +                // An IOException on a write is almost always due to
  +                // the remote client aborting the request.  Wrap this
  +                // so that it can be handled better by the error dispatcher.
  +                throw new ClientAbortException(e);
  +            }
           }
   
       }