I agree with your (2) statement below, at least if Apache is running on 
Windows.  Flushing doesn't really help, as there is a specific issue with 
buffering in Apache on Windows.  We had to introduce a patch to 
HTTP_PROTOCOL.C that someone posted in a newsgroup to solve the 
problem.  It's comment pretty much summarizes the details:

/*
  * WIN32 pipes will ALWAYS block until data arrives,
  * therefore the ap_bread() will NEVER return 0,
  * therefore we will never flush r->connection->client,
  * therefore the client will only get data when we have
  * pushed in enough to write to the socket (IOBUFSIZE
  * probably) or the script finishes,
  * therefore server push does not work.
  * Work around this by always flushing before a read.
  * This is probably quite inefficient in some cases.
  */
if (ap_bflush(r->connection->client) < 0) {
     ap_log_rerror(APLOG_MARK, APLOG_INFO, r,
         "client stopped connection before send body completed");
     ap_bsetflag(r->connection->client, B_EOUT, 1);
     r->connection->aborted = 1;
     break;
}

If you can't find the details of this patch, let me know and I'll send you 
a copy of the file.  Unfortunately, though, it means you'll have to set up 
a build environment for Windows (which is something we didn't have to do 
before).

Jay

-----Original Message-----
From: William Kaufman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 5:00 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Servlet --> File --> Web-browser


I didn't answer, because I'd hoped someone could say for sure.  But my own
guesses are:

1) The "Cancel" button in IE doesn't actually do anything once the data
starts streaming.  I've suspected this was the case, and it sounds like
you've got evidence.

2) Apache is buffering the response somehow: directly connected to Netscape,
you get an immediate exception when writing to a closed stream; but, with
Apache in the middle, the writes don't happen immediately, and no exception
is propagated to the servlet.

My only advice would be to flush your servlet output early and often: you
might (or might not) get an exception immediately.

                                                             -- Bill K.


 > -----Original Message-----
 > From: alan leung [mailto:[EMAIL PROTECTED]]
 > Sent: Thursday, May 03, 2001 10:43 AM
 > To: [EMAIL PROTECTED]
 > Subject: Re: Servlet --> File --> Web-browser
 >
 >
 > can any one helps me out?
 > thanks again.
 >
 > --- alan leung <[EMAIL PROTECTED]> wrote:
 > > Hi,
 > > I have a servlet reads a file from FileInputStream
 > > and
 > > copy those bytes to ServletOutputStream and send
 > > back
 > > to web browser.
 > >
 > > But if user click CANCEL while downloading in
 > > netscape. i will get an exception in doGet method.
 > > -->
 > > IOException in doGet(): java.net.SocketException:
 > > Connection aborted by peer: socket write error
 > >
 > > if user click CANCEL in IE (Internet Explorer). i
 > > didn't get any exception print out.
 > >
 > > Both cases is browser connect to servlet engine
 > > directly (tomcat)
 > >
 > > if browser connects to apache server --> then
 > > tomcat;
 > > no exception got caught for netscape and IE if user
 > > click CANCEL while download.
 > >
 > > What i think is clicking CANCEL while downloading a
 > > file would lost the TCP connection without ending
 > > it.
 > > which would always rise an IOException right?  Why
 > > if
 > > i use apache server w/ tomcat or IE connect to
 > > tomcat
 > > directly won't cause IOException in doGet() method?
 > >
 > > thanks.
 > >

-- Jay Burgess
    Delano Technology Corporation
    mailto:[EMAIL PROTECTED]
    (913) 438-9444 x154

Reply via email to