Skip to content

Commit

Permalink
Add workaround for Apache's broken FastCGI module
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 9, 2018
1 parent dc8813f commit 5a9daf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Web change log

## ?.?.? / ????-??-??

## 1.6.4 / 2018-10-09

* Added a workaround for Apache's FastCGI not being able to handle
chunked transfer encoding in combination with gzip, see
https://bz.apache.org/bugzilla/show_bug.cgi?id=53332
(@johannes85, @thekid)

## 1.6.3 / 2018-10-09

* Fixed "CONTENT_LENGTH" and "CONTENT_TYPE" request meta-variables
Expand Down
12 changes: 10 additions & 2 deletions src/main/php/xp/web/SAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,21 @@ public function __construct() {
}

/**
* Uses chunked TE for HTTP/1.1, buffering for HTTP/1.0
* Uses chunked TE for HTTP/1.1, buffering for HTTP/1.0 or when using
* Apache and FastCGI, which is broken.
*
* @return web.io.Output
* @see https://tools.ietf.org/html/rfc2068#section-19.7.1
* @see https://bz.apache.org/bugzilla/show_bug.cgi?id=53332
*/
public function stream() {
return $this->version() < '1.1' ? new Buffered($this) : new WriteChunks($this);
$buffered= (
isset($_SERVER['GATEWAY_INTERFACE']) &&
stristr($_SERVER['GATEWAY_INTERFACE'], 'CGI') &&
stristr($_SERVER['SERVER_SOFTWARE'], 'Apache')
) || $_SERVER['SERVER_PROTOCOL'] < 'HTTP/1.1';

return $buffered ? new Buffered($this) : new WriteChunks($this);
}

/**
Expand Down

0 comments on commit 5a9daf0

Please sign in to comment.