Item12105: FastCGIEngineContrib may issue body before headers

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.6
Target Release: patch
Applies To: Engine
Component:
Branches: Release01x01 trunk master
Reported By: JeanBaptisteMayer
Waiting For:
Last Change By: OlivierRaginel
Hi,

There is an inconsistency in how CGI-derived engines issue the header part and the body part of the response.

The impact is that FastCGIEngineContrib is unusable on my setup (perl 5.12.4), with Apache complaining about invalid headers (or - more precisely - the lack thereof).

lib/Foswiki/Engine/CGI.pm issues headers using perl's print method, while lib/Foswiki/Engine.pm sends the body using lib/Foswiki/Engine/CGI.pm 's write method.

FastCGI.pm reimplements the write method using syswrite, which is not buffered, and thus can be sent to the webserver before the headers.

I successfully tested the below fix - both in FastCGI and Legacy environments:

Modify the finalizeHeaders method in lib/Foswiki/Engine/CGI.pm and replace print with $this->write

-- JeanBaptisteMayer - 30 Sep 2012

I do not really understand why Gilmar used syswrite in FastCGIEngineContrib and print in the default Engine, but I agree all output should go through the write() sub.

Also updated the copyright (to the end, didn't think of updating the time), and used $_[1] for speed (even though arguably this code shouldn't be called often, most certainly only twice per request).

-- OlivierRaginel - 30 Sep 2012

I recently saw this issue in 1.1.5; I confirm that the fix solved my problem.

-- KipLubliner - 21 Nov 2012
 
Topic revision: r7 - 08 Jun 2015, OlivierRaginel
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy