Re: fsockopen() and POST

From: Date: Sat, 06 Jan 2001 01:15:18 +0000
Subject: Re: fsockopen() and POST
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32989@lists.php.net to get a copy of this message
In article <3A4D156C.98E03DD1@aristesoftware.com>, "Todd Cary" <todd@aristesoftware.com> wrote: > I am trying to send data via a socket and the POST method. I have no > problems with the GET, but the POST is not putting anything into the > $HTTP_POST_VARS array. Here is what I am sending: > > POST http://209.204.172.138:80/hec/php/purchaseinfo.php > HTTP/1.0 Host: > 209.204.172.137:80 Content-type: application/x-www-form-urlencoded > Content-length: 11 test=123456 > I am assuming that between each header key/value pair you are entering both a carriage return (\r) and a newline (\n). After your last header field and the start of your POST data, you need to include 2 cr and newlines (\r\n\r\n). Should be okay after that. A code snippet: fputs($fp, "POST $scriptPath HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); if (is_array($cookies)) { while (list($key, $val) = each($cookies)) { fputs($fp, "Cookie: $key=$val\r\n"); } } fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($POSTvars)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $POSTvars); Jeff > Is there some glaring error?? > > Todd > > -- > Todd Cary Ariste Software todd@aristesoftware.com > >

« previous php.general (#32989) next »