Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Internet/Apache Shared Module    [ Add a report in this area ]  
Report #:  5129   Status: Reported
Early response from webpage
Project:  Delphi Build #:  4453
Version:    7.0 Submitted By:   Thomas van Rompaey
Report Type:  Basic functionality failure Date Reported:  7/10/2003 12:35:03 AM
Severity:    Critical / Show Stopper Last Updated: 7/10/2003 12:41:58 AM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
Case:
We generate a PDF document in our WebSnap application and while the data for this report is being collected we want to send  some text to the client-browser so he knows the report is being generated. For example :
1. Opening report...
2. Retreiving data...
3. Applying formatting...
4. Sending report...
In ISAPI it works perfectlly to send a web response early but on Apache 1.3 the data isn't send to the browser until the last response is ready. Look for more info in the BDN article 22866.

When I create a PHP program that does this on the same server it works ok so I asume the problem is not Apache.

I have used packet-sniffing software to verify the data is send to the client in one packet over the network. (so IE6 isn't the problem)

Server: Windows 2000
WebServer: Apache 1.3.27
Client browser: IE 6
Steps to Reproduce:
1) Create a new Web server application
2) Add a action with the following code:

procedure TWebModule1.WebModule1test3Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  I: Integer;
  S: string;
begin
  // Important that this is first!
  Response.SendResponse;
  S := 'About to send time stamps<br>';
  // Send the content early by accessing the Request
  // directly and writing to it.
  Request.WriteString(S);
  // Send some Responses and pause to simulate lengthy operations
  for I := 1 to 3 do
  begin
    // Pause for about 3 secs
    Sleep(3000);
    // Set another response
    S := TimeToStr(Now) + '<br>';
    Request.WriteString(S);
  end;
end;

3) Run it on Apache

You could also try the following code because it implements HTTP1.1:

procedure TWebModule1.WebModule1testAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);

  procedure SendChunk(const Value: String; IsHTTP11: Boolean);
  begin
    if IsHTTP11 then
      Request.WriteString(IntToHex(Length(Value),0) + #13#10 + Value + #13#10)
    else
      If Value <> '' then
        Request.WriteString(Value);
  end;
var
  IsHTTP11: Boolean;
begin
  IsHTTP11 := Request.ProtocolVersion = 'HTTP/1.1';
  if IsHTTP11 then
    Response.SetCustomHeader('Transfer-Encoding','chunked');

  //Session.UpdateResponse(response);
  Response.SendResponse;

  // The first packet should be at least 256 bytes
  SendChunk(DupeString(' ', 300) + '<HTML><BODY>', IsHTTP11);

  SendChunk('Begin<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('Row 1<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('Row 2<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('Row 3<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('Row 4<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('Row 5<BR>', IsHTTP11);
  sleep(1000);
  SendChunk('End<BR>', IsHTTP11);

  SendChunk('</BODY></HTML>', IsHTTP11);
  SendChunk('', IsHTTP11);

  Handled := True;
end;
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01