Skip to content

Fix #81305: Built-in Webserver Drops Requests With "Upgrade" Header #7316

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
5 changes: 5 additions & 0 deletions sapi/cli/php_http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,16 @@ size_t php_http_parser_execute (php_http_parser *parser,
}
}

/* We cannot meaningfully support upgrade requests, since we only
* support HTTP/1 for now.
*/
#if 0
/* Exit, the rest of the connect is in a different protocol. */
if (parser->upgrade) {
CALLBACK2(message_complete);
return (p - data);
}
#endif

if (parser->flags & F_SKIPBODY) {
CALLBACK2(message_complete);
Expand Down
36 changes: 36 additions & 0 deletions sapi/cli/tests/bug81305.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Bug #81305 (Built-in Webserver Drops Requests With "Upgrade" Header)
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start();

$host = PHP_CLI_SERVER_HOSTNAME;
$fp = php_cli_server_connect();

if (fwrite($fp, <<<HEADER
GET / HTTP/1.1
Host: {$host}
Upgrade: HTTP/2.0
Connection: upgrade


HEADER)) {
fpassthru($fp);
}

fclose($fp);
?>
--EXPECTF--
HTTP/1.1 200 OK
Host: %s
Date: %s
Connection: close
X-Powered-By: PHP/%s
Content-type: text/html; charset=UTF-8

Hello world