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 #2158

HTTP_Server_Request storing POST data

Details

Request #2158HTTP_Server_Request storing POST data
Submitted2004-08-18 13:44 UTC
Fromivan at oxylus dot si
Assignedschst
StatusClosed
PackageHTTP_Server
PHP Version5.0.0
OSLinux
Roadmaps(Not assigned)

Comments

[2004-08-18 13:44 UTC] ivan at oxylus dot si

Description:
------------
Function parse() only stores headers information into $request->headers. In case of POST request, it would also be wise to return POST data.

I've made a quick fix in parse() function of HTTP/Server/Request.php that stores all lines not matching the regexp into $request->data array.

I've put the modified part of the parse() function that parses the headers into the $request->headers into "Reproduce code".

Reproduce code:
---------------
// parse and store additional headers (not needed, but nice to have)
for ($i = 1; $i < count($lines); $i++) {
$regs = array();
if (preg_match("'([^: ]+): (.+)'", $lines[$i], $regs)) {
$request->headers[(strtolower($regs[1]))] = $regs[2];
} else { // store everything else in data[] array.
$request->data[] = $lines[$i];
}
}
return $request;

[2004-11-15 22:45 UTC] cox at idecnet dot com

Yet another solution which doesn't touch the original body:

// split lines

$headers = preg_split("/\r\n\r\n/s", $request, 2);

$lines = $headers[0];

$body = !empty($headers[1]) ? $headers[1] : '';

$lines = preg_split("/\r\n/", $lines);
[...]
$request->body = $body;

[2004-11-16 09:46 UTC] cox at idecnet dot com

Just for the records, Net_Server stores the whole request in memory, this is a seriuos problem if you want transmit big files.