When set to TRUE, the entire URI will be used when
constructing the request. (i.e.
GET http://www.example.com/path/to/file.html HTTP/1.0).
While this is a non-standard request format, some
proxy servers require it.

Notes

Note:
Underlying socket stream context options
Additional context options may be supported by the
underlying transport
For http:// streams, refer to context
options for the tcp:// transport. For
https:// streams, refer to context options
for the ssl:// transport.

Note:
HTTP status line
When this stream wrapper follows a redirect, the
wrapper_data returned by
stream_get_meta_data() might not necessarily contain
the HTTP status line that actually applies to the content data at index
0.

See Also

User Contributed Notes 9 notes

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:

If you use the proxy server and encounter an error "fopen(http://example.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.

note that both http and https transports require the same context name http

// OK example:// this will work as expected// note the url with https but context with http$correct_data = file_get_contents('https://example.com', false, stream_context_create(array('http' => array(...))));

// INVALID example:// this will not work, the context will be ignored// note the url with https also context with https$correct_data = file_get_contents('https://example.com', false, stream_context_create(array('https' => array(...))));

note that for both http and https protocols require the same 'http' context keyword:

<?php

// CORRECT example:// this will work as expected// note the url with https but context with http$correct_data = file_get_contents('https://example.com', false, stream_context_create(array('http' => array(...))));

// INVALID example:// this will not work, the context will be ignored// note the url with https also context with https$correct_data = file_get_contents('https://example.com', false, stream_context_create(array('https' => array(...))));

I had quite a bit of trouble trying to make a request with fopen through a proxy to a secure url. I kept getting a 400 Bad Request back from the remote host. It was receiving the proxy url as the SNI host. In order to get around this I had to explicity set the SNI host to the domain I was trying to reach. It's apparently the issue outlined in this bug: