Hi all,

I've got a little servlet that keeps the HTTP connection streams data (html 
script data, to be precise) at the rate of a few bytes per second.  Tomcat 
handled this fine, but as soon as I routed it through Apache using the warp 
connector, I found that data was not sent until the connection was closed 
(never, in the case of my servlet.) 

Traced the problem down to WarpResponse.java: for some reason it was 
inheriting its stream from OutputStream instead of ServletOutputStream, 
which was causing all sorts of problems.  Also made sure it flushed the 
headers before trying to write body data. 

Seems to be going fine now, but this is my first patch so treat with 
caution! 

 --
Roger Nesbitt 

--- 
/root/wa/jakarta-tomcat-connectors/webapp/java/org/apache/catalina/connector/warp/WarpResponse.java
 Thu Jan 24 06:48:50 2002
+++ WarpResponse.java   Wed Feb  6 15:54:28 2002
@@ -71,6 +71,7 @@
 import java.util.Locale;
 import java.util.TimeZone;
 import javax.servlet.ServletResponse;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -101,6 +102,21 @@
         this.setStream(localstream);
     }
 
+    /**
+     * Returns the warp OutputStream 
+     */
+    public ServletOutputStream getOutputStream() { return localstream; }
+
+    /**
+     * Flush the buffer and commit this response.
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public void flushBuffer() throws IOException { localstream.flush(); }
+
+    public int getBufferSize() { return localstream.packet.buffer.length; }
+    public void setBufferSize(int size) {}
+
     /**
      * Recycle this <code>WarpResponse</code> instance.
      */
@@ -248,7 +264,7 @@
      * The <code>OutputStream</code> that will handle all response body
      * transmission.
      */
-    protected class Stream extends OutputStream {
+    protected class Stream extends ServletOutputStream {
         /** The response associated with this stream instance. */
         private WarpResponse response=null;
         /** The packet used by this stream instance. */
@@ -285,6 +301,7 @@
         public void flush()
         throws IOException {
             if (closed) throw new IOException("Stream closed");
+            if (!response.isCommitted()) response.sendHeaders();            
             packet.setType(Constants.TYPE_RES_BODY);
             response.getConnection().send(packet);
             packet.reset();


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

Reply via email to