Item12105: FastCGIEngineContrib may issue body before headers

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

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/ issues headers using perl's print method, while lib/Foswiki/ sends the body using lib/Foswiki/Engine/ 's write method. 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/ 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