PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Server » Bug #3116

HTTP response message does not contain CRLF

Details

Submitted2005-01-05 19:39 UTC
Fromvincent at dauphin-mm dot nl
Assignedcweiske
StatusClosed
PackageHTTP_Server
PHP Version4.3.9
OSlinux
Roadmaps(Not assigned)

Comments

[2005-01-05 19:39 UTC] vincent at dauphin-mm dot nl

Description:
------------
The function _sendResponse() in class HTTP_Server generates a response where the status-line and headers don't end with CRLF, but only with LF.

This can be fix with the following patch:

--- Server.php.orig 2005-01-05 20:38:47.100824286 +0100
+++ Server.php 2005-01-05 20:37:10.018097924 +0100
@@ -265,7 +265,7 @@
$response["code_translated"] = $this->_resolveStatusCode($response["code"]);

// send the response code
- $this->_driver->sendData($clientId, sprintf("HTTP/1.0 %s %s\n", $response["code"], $response["code_translated"]));
+ $this->_driver->sendData($clientId, sprintf("HTTP/1.0 %s %s\r\n", $response["code"], $response["code_translated"]));

// check for headers
if (!isset($response["headers"]) || (!is_array($response["headers"])) ) {
@@ -288,13 +288,13 @@

// send the headers
foreach($response["headers"] as $header => $value) {
- $this->_driver->sendData($clientId, sprintf("%s: %s\n", $header, $value));
+ $this->_driver->sendData($clientId, sprintf("%s: %s\r\n", $header, $value));
}

// send the response body
if (isset($response["body"])) {
- $this->_driver->sendData($clientId, "\n");
+ $this->_driver->sendData($clientId, "\r\n");
if (is_string($response["body"])) {
$this->_driver->sendData($clientId, $response["body"]);
}