Skip to content

Make http stream wrapper advertise HTTP/1.1 by default #5899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ PHP 8.0 UPGRADE NOTES
accept parameters by reference will now warn if a callback with reference
parameters is used. Examples include array_filter() and array_reduce().
This was already the case for most, but not all, functions previously.
. The HTTP stream wrapper as used by functions like file_get_contents()
now advertises HTTP/1.1 rather than HTTP/1.0 by default. This does not
change the behaviour of the client, but may cause servers to respond
differently. To retain the old behaviour, set the 'protocol_version'
stream context option, e.g.

$ctx = stream_context_create(['http' => ['protocol_version' => '1.0']]);
echo file_get_contents('http://example.org', false, $ctx);

- Sysvmsg:
. msg_get_queue() will now return an SysvMessageQueue object rather than a
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/http_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
smart_str_appends(&req_buf, "\r\n");
efree(protocol_version);
} else {
smart_str_appends(&req_buf, " HTTP/1.0\r\n");
smart_str_appends(&req_buf, " HTTP/1.1\r\n");
}

if (context && (tmpzval = php_stream_context_get_option(context, "http", "header")) != NULL) {
Expand Down
6 changes: 3 additions & 3 deletions sapi/cli/tests/bug69655.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ foreach (['MKCO', 'MKCOLL', 'M'] as $method) {
}
?>
--EXPECTF--
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
in %s on line %d

Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
in %s on line %d

Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
Warning: file_get_contents(http://localhost:8964): Failed to open stream: HTTP request failed! HTTP/1.1 501 Not Implemented
in %s on line %d
4 changes: 2 additions & 2 deletions sapi/cli/tests/bug70264.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/..\\CREDITS");
echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/..%5CCREDITS");
?>
--EXPECTF--
Warning: file_get_contents(http://%s/..\CREDITS): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Warning: file_get_contents(http://%s/..\CREDITS): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in %sbug70264.php on line %d

Warning: file_get_contents(http://%s/..%5CCREDITS): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
Warning: file_get_contents(http://%s/..%5CCREDITS): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in %sbug70264.php on line %d