note 30720 deleted from function.fsockopen by nlopess

From: Date: Sat, 27 Dec 2003 15:19:58 +0000
Subject: note 30720 deleted from function.fsockopen by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62569@lists.php.net to get a copy of this message
Note Submitter: Jack@soinsincere.com ---- I'd like to point out a _major_ pitfall some Windows users might experience while trying to send or receive data from a server when using fsockopen() and fwrite() Your PHP parser probably _won't_ insert a carriage return and newline when using this sort of method for writing a request: fwrite($fp,<<<PING POST /RPC2 HTTP/1.0\r Host: rpc.weblogs.com\r User-Agent: My Pinger version f00\r Content-Length: 233\r Content-Type: text/xml\r \r $myping\r PING ); This will resolve a "Bad Request" error from most servers, or even worse, no response at all, causing a less-careful script to hang indefinitely. To ensure a carriage return followed by a newline, use this method: fwrite($fp, "POST /RPC2 HTTP/1.0\x0D\x0A". Host: rpc.weblogs.com\x0D\x0A". User-Agent: My Pinger version f00\x0D\x0A". Content-Length: 233\x0D\x0A". Content-Type: text/xml\x0D\x0A". "\x0D\x0A". "$myping\x0D\x0A");

« previous php.notes (#62569) next »