Bug #76204 [Opn]: Remove the partial support for the CONNECT method
| From: | cmb@php.net | Date: | Wed, 18 Apr 2018 18:27:32 +0000 |
| Subject: | Bug #76204 [Opn]: Remove the partial support for the CONNECT method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214803@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76204&edit=1
ID: 76204
Updated by: cmb@php.net
Reported by: sid dot pasquale at gmail dot com
Summary: Remove the partial support for the CONNECT method
Status: Open
Type: Bug
Package: Built-in web server
Operating System: linux
PHP Version: 7.0.29
Block user comment: N
Private report: N
New Comment:
FTR: <https://github.com/php/php-src/pull/3220>
Previous Comments:
------------------------------------------------------------------------
[2018-04-10 16:31:39] requinix@php.net
Why...
Yes, it's in there, but it's not actually supported. My guess is that the person who
included CONNECT thought it was like every other verb. It isn't.
A proper implementation of tunneling is beyond the scope of the built-in server. The partial support
in there should be removed.
------------------------------------------------------------------------
[2018-04-10 16:26:02] sid dot pasquale at gmail dot com
"CONNECT" was defined on line 85 of "php_http_parser.c": https://github.com/php/php-src/blob/PHP-7.0.13/sapi/cli/php_http_parser.c#L85
------------------------------------------------------------------------
[2018-04-10 16:14:41] sid dot pasquale at gmail dot com
So the expected result should be "501 Not Implemented".
Furthermore "CONNECT" (like PATCH) seems to be implemented:
https://github.com/php/php-src/search?utf8=%E2%9C%93&q=PHP_HTTP_CONNECT&type=
Working "PATCH" example:
sid@zen:~$ echo -en "PATCH / HTTP/1.1\r\n\r\n" | nc localhost 8080 | head -n 1
HTTP/1.1 404 Not Found
------------------------------------------------------------------------
[2018-04-10 16:05:05] requinix@php.net
CONNECT is not supported because the built-in server is a simple server for simple development uses.
See request #72619.
------------------------------------------------------------------------
[2018-04-10 15:59:15] sid dot pasquale at gmail dot com
Description:
------------
PHP HTTP built-in server doesn't support CONNECT HTTP method
Test script:
---------------
Starting built-in server:
sid@zen:~$ php -S 127.0.0.1:8080
Test with some working HTTP methods:
sid@zen:~$ echo -en "GET / HTTP/1.1\r\n\r\n" | nc localhost 8080 | head -n 1
HTTP/1.1 404 Not Found
sid@zen:~$ echo -en "FOO / HTTP/1.1\r\n\r\n" | nc localhost 8080 | head -n 1
HTTP/1.1 501 Not Implemented
Not working:
sid@zen:~$ echo -en "CONNECT www.example.com:443 HTTP/1.1\r\n\r\n" | nc localhost 8080 |
head -n 1
Actual result:
--------------
[Tue Apr 10 17:51:27 2018] 127.0.0.1:44676 Invalid request (Malformed HTTP request)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76204&edit=1