Re: fsock sending bad request

From: Date: Thu, 23 Oct 2003 13:59:21 +0000
Subject: Re: fsock sending bad request
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-167267@lists.php.net to get a copy of this message
hi, deo> $header.= "$req\n"; Tom is right but as usual IIS is wrong and expects it :-( so better to use it anyway. deo> $fp = fsockopen("host", "80", $errno, $errstr, $timeout = 30); errno and errstr will not be set unless you pass it by reference. deo> $header.= "Host: host\r\n"; Host header is usually used only with HTTP/1.1 all the best daniel@electroteque.org wrote:
$req = "&field=1"; its the data i need to post
Hi, Thursday, October 23, 2003, 7:58:19 AM, you wrote: deo> Hi there the following code doesnt seem to work, i am getting a bad request deo> sent back from the server, what could be the problem of something so deo> simple ? deo> $header .= "POST test.php HTTP/1.0\r\n"; deo> $header.= "Host: host\r\n"; deo> $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; deo> $header .= 'Content-Length: ' . strlen($req) . "\n\n"; deo> $header .= "Connection: close\n\n"; deo> $header.= "\r\n"; deo> if (!$fp) { deo> // ERROR deo> echo "$errstr ($errno)"; deo> } else { deo> //put the data.. deo> fputs ($fp, $header . $req); deo> while (!feof($fp)) { deo> //read the data returned...
deo>     $res = fgets ($fp, 1024);
deo> echo $res; deo> } deo> fclose ($fp); deo> } you probably don't need this in the header $header.= "$req\n"; but I have no idea what $req contains -- regards, Tom
-- Raditha Dissanayake. ------------------------------------------------------------------------ http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar.

« previous php.general (#167267) next »