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:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC