note 97493 added to function.curl-setopt

From: Date: Thu, 22 Apr 2010 22:11:48 +0000
Subject: note 97493 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-168524@lists.php.net to get a copy of this message
I couldn't find a way to force a curl request to go to a particular IP address, but you can do it with fsockopen: <?php $ip = '123.45.67.89'; $fp = fsockopen($ip, 80, $errno, $errstr, 5); $result = ''; if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /path/to/the/file.ext HTTP/1.1\r\n"; $out .= "Host: www.mydomain.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { $result .= fgets($fp, 128); } fclose($fp); } ?> I needed it to test the response from a set of servers behind a load balancer. ---- Server IP: 192.41.40.227 Probable Submitter: 67.134.147.188 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/97493 Del: integrated -- https://master.php.net/note/delete/97493/integrated Del: useless -- https://master.php.net/note/delete/97493/useless Del: bad code -- https://master.php.net/note/delete/97493/bad+code Del: spam -- https://master.php.net/note/delete/97493/spam Del: non-english -- https://master.php.net/note/delete/97493/non-english Del: in docs -- https://master.php.net/note/delete/97493/in+docs Del: other reasons-- https://master.php.net/note/delete/97493 Reject -- https://master.php.net/note/reject/97493 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168524) next »