[fpc-devel] fpweb is not showing the exception message [Found the problem]

ABorka fpc-devel at aborka.com
Wed Apr 13 10:19:02 CEST 2011


On 4/13/2011 00:07, michael.vancanneyt at wisa.be wrote:
>>>> On Mon, 11 Apr 2011, ABorka wrote:
<...snip...>
>> 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.
>
> Probably it more depends on the configuration of the Webserver.
> As far as I know, the 'content length' header is purely optional.
> In each case, I'll patch fpWeb so it sets the content length (if possible)
>
> Michael.

Michael, if I do an
   Application.ProtocolOptions := Application.ProtocolOptions + 
[poStripContentLength];
before the
   Application.Run;
for the FCGI application, then it fixes the problem.
Of course, this does not work for CGI apps.

AB





More information about the fpc-devel mailing list