note 110449 added to context.http
| From: | vchampion at gmail dot com | Date: | Tue, 23 Oct 2012 13:41:32 +0000 |
| Subject: | note 110449 added to context.http | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191501@lists.php.net to get a copy of this message | ||
If you use the proxy server and encounter an error "fopen(http://someurl.com): failed to open
stream: HTTP request failed! HTTP/1.0 400 Bad Request" note that in many situations you need
also set the parameter "request_fulluri" to "true" in your stream options.
Without this option the php script sends the empty request to the server as "GET /
HTTP/0.0" and the proxy server replies to it with the "HTTP 400" error.
For example (working sample):
<?php
$stream = stream_context_create(Array("http" => Array("method" =>
"GET",
"timeout" => 20,
"header" => "User-agent:
Myagent",
"proxy" =>
"tcp://my-proxy.localnet:3128",
'request_fulluri' => True /*
without this option we get an HTTP error! */
)));
if ( $fp = fopen("http://someurl.com",
'r', false, $stream) ) {
print "well done";
}
?>
P>S> PHP 5.3.17
----
Server IP: 69.147.83.199
Probable Submitter: 83.69.226.209
----
Manual Page -- http://www.php.net/manual/en/context.http.php
Edit -- https://master.php.net/note/edit/110449
Del: integrated -- https://master.php.net/note/delete/110449/integrated
Del: useless -- https://master.php.net/note/delete/110449/useless
Del: bad code -- https://master.php.net/note/delete/110449/bad+code
Del: spam -- https://master.php.net/note/delete/110449/spam
Del: non-english -- https://master.php.net/note/delete/110449/non-english
Del: in docs -- https://master.php.net/note/delete/110449/in+docs
Del: other reasons-- https://master.php.net/note/delete/110449
Reject -- https://master.php.net/note/reject/110449
Search -- https://master.php.net/manage/user-notes.php