note 101893 added to function.http-parse-message
| From: | A dot S dot at osu1 dot php dot net | Date: | Sun, 16 Jan 2011 23:02:47 +0000 |
| Subject: | note 101893 added to function.http-parse-message | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175807@lists.php.net to get a copy of this message | ||
A useful function, but I couldn't use it because it's not installed on my host.
Here's an alternative I found at http://snipplr.com/view/17242/parse-http-response/
:
function parse_http_response ($string)
{
$headers = array();
$content = '';
$str = strtok($string, "\n");
$h = null;
while ($str !== false) {
if ($h and trim($str) === '') {
$h = false;
continue;
}
if ($h !== false and false !== strpos($str, ':')) {
$h = true;
list($headername, $headervalue) = explode(':', trim($str), 2);
$headername = strtolower($headername);
$headervalue = ltrim($headervalue);
if (isset($headers[$headername]))
$headers[$headername] .= ',' . $headervalue;
else
$headers[$headername] = $headervalue;
}
if ($h === false) {
$content .= $str."\n";
}
$str = strtok("\n");
}
return array($headers, trim($content));
}
----
Server IP: 69.147.83.197
Probable Submitter: 173.166.142.162
----
Manual Page -- http://www.php.net/manual/en/function.http-parse-message.php
Edit -- https://master.php.net/note/edit/101893
Del: integrated -- https://master.php.net/note/delete/101893/integrated
Del: useless -- https://master.php.net/note/delete/101893/useless
Del: bad code -- https://master.php.net/note/delete/101893/bad+code
Del: spam -- https://master.php.net/note/delete/101893/spam
Del: non-english -- https://master.php.net/note/delete/101893/non-english
Del: in docs -- https://master.php.net/note/delete/101893/in+docs
Del: other reasons-- https://master.php.net/note/delete/101893
Reject -- https://master.php.net/note/reject/101893
Search -- https://master.php.net/manage/user-notes.php