On 4/12/2011 01:31, ABorka wrote:
On 4/12/2011 00:01, michael.vancann...@wisa.be wrote:


On Mon, 11 Apr 2011, ABorka wrote:

I was playing today with fpweb a little, and found a simply
reproducible minor problem.

When one creates a new CGI or FCGI application and creates a simple
default action, but NOT setting the "handled := true;" within the
event handler, then some kind of exception happens within fpweb when
the action is called from the client browser, but it does not return a
full response error message page.
All that comes back to the client is:

"<html><head><title>APPNAME: "

where the APPNAME is the title for the application. This happens at
least for CGI and FCGI applications, not sure about Apache modules as
I did not try that.
As soon, as we have "handled := true;" there, everything is OK.
If we have "handled := false;" or simply not setting it, the above
issue happens. It seems, that there is a problem with displaying error
messages/exceptions from within fpweb internals.

/Latest FPC and Lazarus SVN, WinXP 32bit/

I cannot reproduce this at least on Linux 64 bit and Windows 2000 32bit.

I am working with these things full-time at the moment, and I always get
the full page.

Michael.

Yes, it works for me too in Linux 32bit.

But not in WinXP 32bit. In fact, it seems that no matter what, the
response page is cut off at 30 characters. In custweb.pp of
.../fcl-web/base/ ,

procedure ExceptionToHTML(S: TStrings; const E: Exception; const Title,
Email, Administrator: string);

assembles the response page, and for some reason S is only 30 characters
maximum when it arrives to the client browser.
If I replace the inner part of this procedure with simply

With S do
begin
Add('<html><head>longer than 30 characters here..........');
end;

it is still cut at 30 characters. Odd :)


AB

OK, found the problem:

fpweb does not set the content length properly when there was an exception or error message, it uses the content length from the action event handler.
For example, if we have
===============
procedure TFPWebModule1.DefActionRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
begin
//  Handled := true; //commented out to trigger the exception error page
  AResponse.Content := '<html><body>Yo! (F)CGI works!</body></html>';
end;
===============
fpweb will send the content length in the response headers as the length of the string set in the event handler which is the length of '<html><body>Yo! (F)CGI works!</body></html>'#13#10 in this case, and not the length of the error response page it constructs and sends back.

Headers>
Status: 200 OK
Content-Length: 45
Content-Type: text/html

This is happening on Windows XP 32bit for me for both CGI and FCGI applications if the above example is used. I would not be surprised if this problem would be there in Linux too, maybe it is just properly displayed in the browser there, no matter what the header says.

AB

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to