Skip to content

Commit 4645a9d

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #81305: Built-in Webserver Drops Requests With "Upgrade" Header
2 parents 840e441 + d1ccb5b commit 4645a9d

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
. Fixed bug #72595 (php_output_handler_append illegal write access). (cmb)
77
. Fixed bug #66719 (Weird behaviour when using get_called_class() with
88
call_user_func()). (Nikita)
9+
. Fixed bug #81305 (Built-in Webserver Drops Requests With "Upgrade" Header).
10+
(cmb)
911

1012
- BCMath:
1113
. Fixed bug #78238 (BCMath returns "-0"). (cmb)

sapi/cli/php_http_parser.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,11 +1339,16 @@ size_t php_http_parser_execute (php_http_parser *parser,
13391339
}
13401340
}
13411341

1342+
/* We cannot meaningfully support upgrade requests, since we only
1343+
* support HTTP/1 for now.
1344+
*/
1345+
#if 0
13421346
/* Exit, the rest of the connect is in a different protocol. */
13431347
if (parser->upgrade) {
13441348
CALLBACK2(message_complete);
13451349
return (p - data);
13461350
}
1351+
#endif
13471352

13481353
if (parser->flags & F_SKIPBODY) {
13491354
CALLBACK2(message_complete);

sapi/cli/tests/bug81305.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Bug #81305 (Built-in Webserver Drops Requests With "Upgrade" Header)
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
?>
7+
--FILE--
8+
<?php
9+
include "php_cli_server.inc";
10+
php_cli_server_start();
11+
12+
$host = PHP_CLI_SERVER_HOSTNAME;
13+
$fp = php_cli_server_connect();
14+
15+
if (fwrite($fp, <<<HEADER
16+
GET / HTTP/1.1
17+
Host: {$host}
18+
Upgrade: HTTP/2.0
19+
Connection: upgrade
20+
21+
22+
HEADER)) {
23+
fpassthru($fp);
24+
}
25+
26+
fclose($fp);
27+
?>
28+
--EXPECTF--
29+
HTTP/1.1 200 OK
30+
Host: %s
31+
Date: %s
32+
Connection: close
33+
X-Powered-By: PHP/%s
34+
Content-type: text/html; charset=UTF-8
35+
36+
Hello world

0 commit comments

Comments
 (0)