note 114867 added to context.http
| From: | nate | Date: | Thu, 17 Apr 2014 03:19:39 +0000 |
| Subject: | note 114867 added to context.http | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199285@lists.php.net to get a copy of this message | ||
Note that if you set the protocol_version option to 1.1 and the server you are requesting from is
configured to use keep-alive connections, the function (fopen, file_get_contents, etc.) will
"be slow" and take a long time to complete. This is a feature of the HTTP 1.1 protocol you
are unlikely to use with stream contexts in PHP.
Simply add a "Connection: close" header to the request to eliminate the keep-alive
timeout:
<?php
// php 5.4 : array syntax and header option with array value
$data = file_get_contents('http://www.example.com/', null,
stream_context_create([
'http' => [
'protocol_version' => 1.1,
'header' => [
'Connection: close',
],
],
]));
?>
----
Server IP: 216.235.13.26
Probable Submitter: 173.177.132.92
----
Manual Page -- http://php.net/manual/en/context.http.php
Edit -- https://master.php.net/note/edit/114867
Del: integrated -- https://master.php.net/note/delete/114867/integrated
Del: useless -- https://master.php.net/note/delete/114867/useless
Del: bad code -- https://master.php.net/note/delete/114867/bad+code
Del: spam -- https://master.php.net/note/delete/114867/spam
Del: non-english -- https://master.php.net/note/delete/114867/non-english
Del: in docs -- https://master.php.net/note/delete/114867/in+docs
Del: other reasons-- https://master.php.net/note/delete/114867
Reject -- https://master.php.net/note/reject/114867
Search -- https://master.php.net/manage/user-notes.php