php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72619 Add support for arbitrary HTTP methods
Submitted: 2016-07-19 04:56 UTC Modified: 2016-07-21 23:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nazar at mokrynskyi dot com Assigned:
Status: Open Package: Built-in web server
PHP Version: 7.0.8 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nazar at mokrynskyi dot com
New email:
PHP Version: OS:

 

 [2016-07-19 04:56 UTC] nazar at mokrynskyi dot com
Description:
------------
Similar to https://bugs.php.net/bug.php?id=61679, but with non-existing file path (handled by index.php).

1) > touch index.php
2) > php -S localhost:1234 index.php
3) Execute test script in another terminal

Test script:
---------------
<?php
file_get_contents(
	'http://localhost:1234/some-path',
	null,
	stream_context_create(
		[
			'http' => [
				'method' => 'PATCH'
			]
		]
	)
);
file_get_contents(
	'http://localhost:1234/some-path',
	null,
	stream_context_create(
		[
			'http' => [
				'method' => 'XYZ_METHOD_ALSO_ALLOWED'
			]
		]
	)
);


Expected result:
----------------
Empty output both in test script and PHP server

Actual result:
--------------
Test script:
PHP Warning:  file_get_contents(http://localhost:1234/some-path): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
 in %s/test.php on line 10
PHP Warning:  file_get_contents(http://localhost:1234/some-path): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
 in %s/test.php on line 21

PHP server:
[%s] 127.0.0.1:%d [501]: /some-path - No such file or directory

Note that PHP server doesn't print anything for PATCH method (for whatever reason, but it is a part of issue anyway).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-21 14:12 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2016-07-21 14:12 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

In particular, read about the meaning of router scripts:

| If a PHP file is given on the command line when the web server
| is started it is treated as a "router" script. The script is run
| at the start of each HTTP request. If this script returns FALSE,
| then the requested resource is returned as-is. Otherwise the
| script's output is returned to the browser.
 [2016-07-21 20:05 UTC] nazar at mokrynskyi dot com
I saw documentation. I do not return FALSE and do output something, yet getting errors for custom HTTP methods, like XYZ_METHOD_ALSO_ALLOWED

I've prepared simple repository for reproducing an issue:
https://github.com/nazar-pc/php-bug-72619
 [2016-07-21 23:34 UTC] cmb@php.net
-Summary: Support for custom HTTP methods not working +Summary: Add support for arbitrary HTTP methods -Status: Not a bug +Status: Open -Operating System: Linux +Operating System: *
 [2016-07-21 23:34 UTC] cmb@php.net
> […], yet getting errors for custom HTTP methods, like
> XYZ_METHOD_ALSO_ALLOWED

Ah, now I see what you're up to: the built-in webserver should
accept any HTTP method! Indeed, that is something to consider, as
I already stated in bug #68875. However, that appears to require
an RFC, see <https://wiki.php.net/rfc/howto>.
 [2016-07-21 23:34 UTC] cmb@php.net
-Type: Bug +Type: Feature/Change Request -Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC