fsock sending bad request
| From: | daniel at electroteque dot org | Date: | Wed, 22 Oct 2003 21:58:19 +0000 |
| Subject: | fsock sending bad request | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-167186@lists.php.net to get a copy of this message | ||
Hi there the following code doesnt seem to work, i am getting a bad request
sent back from the server, what could be the problem of something so
simple ?
$header .= "POST test.php HTTP/1.0\r\n";
$header.= "Host: host\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen($req) . "\n\n";
$header .= "Connection: close\n\n";
$header.= "$req\n";
$header.= "\r\n";
$fp = fsockopen("host", "80", $errno, $errstr, $timeout = 30);
if (!$fp) {
// ERROR
echo "$errstr ($errno)";
} else {
//put the data..
fputs ($fp, $header . $req);
while (!feof($fp)) {
//read the data returned...
$res = fgets ($fp, 1024);
echo $res;
}
fclose ($fp);
}