Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sapi/cli/php_http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static const char *method_strings[] =
, "LOCK"
, "MKCOL"
, "MOVE"
, "MKCALENDAR"
, "PROPFIND"
, "PROPPATCH"
, "SEARCH"
Expand Down Expand Up @@ -585,7 +586,7 @@ size_t php_http_parser_execute (php_http_parser *parser,
case 'G': parser->method = PHP_HTTP_GET; break;
case 'H': parser->method = PHP_HTTP_HEAD; break;
case 'L': parser->method = PHP_HTTP_LOCK; break;
case 'M': parser->method = PHP_HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ break;
case 'M': parser->method = PHP_HTTP_MKCOL; /* or MOVE, MKCALENDAR, MKACTIVITY, MERGE, M-SEARCH */ break;
case 'N': parser->method = PHP_HTTP_NOTIFY; break;
case 'O': parser->method = PHP_HTTP_OPTIONS; break;
case 'P': parser->method = PHP_HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break;
Expand Down Expand Up @@ -623,6 +624,8 @@ size_t php_http_parser_execute (php_http_parser *parser,
} else if (parser->method == PHP_HTTP_MKCOL) {
if (index == 1 && ch == 'O') {
parser->method = PHP_HTTP_MOVE;
} else if (index == 3 && ch == 'A') {
parser->method = PHP_HTTP_MKCALENDAR;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this code works, but I can't get my head around why it works. When control enters with index=1 (and ch=K), I'd expect parser->method to be set to NOT_IMPLEMENTED, so that this branch is not entered again for a higher index.

What am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When control enters with index=1 and ch=K, then another else-if is executed, doing nothing.

} else if (index == 1 && ch == 'E') {
parser->method = PHP_HTTP_MERGE;
} else if (index == 1 && ch == '-') {
Expand Down
1 change: 1 addition & 0 deletions sapi/cli/php_http_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ enum php_http_method
, PHP_HTTP_LOCK
, PHP_HTTP_MKCOL
, PHP_HTTP_MOVE
, PHP_HTTP_MKCALENDAR
, PHP_HTTP_PROPFIND
, PHP_HTTP_PROPPATCH
, PHP_HTTP_SEARCH
Expand Down
5 changes: 1 addition & 4 deletions sapi/cli/tests/bug69655.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include "skipif.inc";
<?php
include "php_cli_server.inc";
php_cli_server_start();
foreach (['MKCALENDAR', 'MKCO', 'MKCOLL', 'M'] as $method) {
foreach (['MKCO', 'MKCOLL', 'M'] as $method) {
$context = stream_context_create(['http' => ['method' => $method]]);
// the following is supposed to emit a warning for unsupported methods
file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context);
Expand All @@ -25,6 +25,3 @@ Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP r

Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
in %s on line %d

Warning: file_get_contents(http://localhost:8964): failed to open stream: HTTP request failed! HTTP/1.0 501 Not Implemented
in %s on line %d
17 changes: 17 additions & 0 deletions sapi/cli/tests/bug69953.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
FR #69953 (Support MKCALENDAR request method)
--INI--
allow_url_fopen=1
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php
include "php_cli_server.inc";
php_cli_server_start('echo $_SERVER["REQUEST_METHOD"];');
$context = stream_context_create(['http' => ['method' => 'MKCALENDAR']]);
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
?>
--EXPECT--
string(10) "MKCALENDAR"