Re: fsock sending bad request

From: Date: Thu, 23 Oct 2003 12:32:18 +0000
Subject: Re: fsock sending bad request
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-167258@lists.php.net to get a copy of this message
$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.= "$req\n"; > deo> $header.= "\r\n"; > > > > > deo> $fp = fsockopen("host", "80", $errno, $errstr, $timeout = 30); > 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

« previous php.general (#167258) next »