Fix #103: header call would hang php development server before

This commit is contained in:
Denis
2013-10-20 10:21:29 +03:00
parent 32597004f7
commit df45025378
+14 -8
View File
@@ -273,14 +273,20 @@ class Run
if($this->sendHttpCode() && isset($_SERVER["REQUEST_URI"]) && !headers_sent()) {
$httpCode = $this->sendHttpCode();
// Using the third argument to set the HTTP status,
// we rely on PHP to set it correctly.
// This allows us to not have hardcoded string values for
// different HTTP status codes, as well as not require us to
// figure out the correct HTTP protocol version.
// Note that this syntax of header requires the first argument
// to be at least a space.
header(' ', true, $httpCode);
if (function_exists('http_response_code')) {
http_response_code($httpCode);
} else {
// http_response_code is added in 5.4.
// For compatibility with 5.3 we use the third argument in header call
// First argument must be a real header.
// If it is empty, PHP will ignore the third argument.
// If it is invalid, such as a single space, Apache will handle it well,
// but the PHP development server will hang.
// Setting a full status line would require us to hardcode
// string values for all different status code, and detect the protocol.
// which is an extra error-prone complexity.
header('X-Ignore-This: 1', true, $httpCode);
}
}
echo $output;