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

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Apr 13 10:40:51 CEST 2011



On Wed, 13 Apr 2011, ABorka wrote:

> 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.

This option removes the Content-Length header.

It seems to me that if content-length is specified, it is used and therefor 
must be correct. I will check this.

Michael.



More information about the fpc-devel mailing list