php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69655 php -S changes MKCALENDAR request method to MKCOL
Submitted: 2015-05-18 15:13 UTC Modified: 2015-06-27 18:47 UTC
From: markus at unterwaditzer dot net Assigned: cmb (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.6.9 OS: Linux
Private report: No CVE-ID: None
 [2015-05-18 15:13 UTC] markus at unterwaditzer dot net
Description:
------------
PHP's built-in web server changes the request method MKCALENDAR to MKCOL.

Serve the given test script with:

    php -S localhost:8080 ./foobar.php

and do a test request with e.g.:

    curl -X MKCALENDAR http://localhost:8080/

Test script:
---------------
<?php echo $_SERVER['REQUEST_METHOD']; ?>

Expected result:
----------------
The response body should be "MKCALENDAR".

Actual result:
--------------
The response body is "MKCOL".

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-18 21:06 UTC] cmb@php.net
-Status: Open +Status: Analyzed
 [2015-05-18 21:06 UTC] cmb@php.net
Actually, MKCALENDAR is not yet supported by the CLI server. When
I do the respective curl request, I get "curl: (52) Empty reply
from server" (PHP 5.6.8 and current master on Windows, curl
running on Cygwin).
 [2015-05-18 23:29 UTC] markus at unterwaditzer dot net
Original discussion: https://github.com/fruux/sabre-dav/issues/603#issuecomment-103086001

Further bugs related to the HTTP request method (in either PHP itself or the HTTP parser it uses) include:

- No response/idling connection with MKCO or MKCOLL as request method.
- Empty reply with M as request method.

It seems http-parser includes some very complex logic to parse the HTTP method performantly: https://github.com/joyent/http-parser/blob/master/http_parser.c#L1008

Total armchair engineering here, but isn't it easier (and performant enough for the builtin server) to just pass the method on to PHP unparsed?
 [2015-06-27 16:31 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2015-06-27 16:31 UTC] cmb@php.net
Indeed, Markus, the issue is not so much that MKCALENDAR is not
implemented, but that the request method parsing is buggy. For
unsupported methods the server is supposed to return "501 Not
Implemented", but that doesn't work for several cases, such as the
ones you've already mentionend. I'm working on a fix.

> [...] isn't it easier (and performant enough for the builtin
> server) to just pass the method on to PHP unparsed?

Certainly something to consider. However, that would not be a bug
fix, but a rather a behavioral change, which might even require an
RFC. Feel free to file a respective feature request. :)
 [2015-06-27 16:42 UTC] cmb@php.net
-Summary: php -S changes MKCALENDAR request method +Summary: php -S changes MKCALENDAR request method to MKCOL
 [2015-06-27 18:07 UTC] cmb@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bbe28d3a55f8b129d4595e5202b7c9891a568509
Log: Fixed #69655: php -S changes MKCALENDAR request method to MKCOL
 [2015-06-27 18:07 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2015-06-27 18:47 UTC] cmb@php.net
The fix for this bug has been committed.

Thank you for the report, and for helping us make PHP better.

Wrt. MKCALENDAR, I have submitted request #69953 and will do a PR
for it.
 [2015-06-30 14:45 UTC] markus at unterwaditzer dot net
Hello cmb,

>Certainly something to consider. However, that would not be a bug fix, but a rather a behavioral change, which might even require an RFC. Feel free to file a respective feature request. :)

I wouldn't consider it a behaviorial change, since existing PHP code is almost
impossible to get broken. The change from a higher perspective is that new
methods are supported: Concretely, all of them.
 [2015-07-07 23:37 UTC] ab@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bbe28d3a55f8b129d4595e5202b7c9891a568509
Log: Fixed #69655: php -S changes MKCALENDAR request method to MKCOL
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC