From 229465cfb7c7cd0529ebf76d00d46101e13d0ee7 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 14 Jul 2015 11:09:03 +0200 Subject: [PATCH 1/2] Add support for MKCALENDAR request method in CLI web server The built-in webserver does not yet implement the MKCALENDAR request method. Let's change that. --- sapi/cli/php_http_parser.c | 5 ++++- sapi/cli/php_http_parser.h | 1 + sapi/cli/tests/bug69953.phpt | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 sapi/cli/tests/bug69953.phpt diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index aa9f28638f479..5f8eb3ce0b19d 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -89,6 +89,7 @@ static const char *method_strings[] = , "LOCK" , "MKCOL" , "MOVE" + , "MKCALENDAR" , "PROPFIND" , "PROPPATCH" , "SEARCH" @@ -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; @@ -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; } else if (index == 1 && ch == 'E') { parser->method = PHP_HTTP_MERGE; } else if (index == 1 && ch == '-') { diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h index 402e7e3c83b9e..fa4873abeb04d 100644 --- a/sapi/cli/php_http_parser.h +++ b/sapi/cli/php_http_parser.h @@ -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 diff --git a/sapi/cli/tests/bug69953.phpt b/sapi/cli/tests/bug69953.phpt new file mode 100644 index 0000000000000..4de41fee40e73 --- /dev/null +++ b/sapi/cli/tests/bug69953.phpt @@ -0,0 +1,17 @@ +--TEST-- +FR #69953 (Support MKCALENDAR request method) +--INI-- +allow_url_fopen=1 +--SKIPIF-- + +--FILE-- + ['method' => 'MKCALENDAR']]); +var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context)); +?> +--EXPECT-- +string(10) "MKCALENDAR" From 5763007a14c1576659f04428efeaa40942409cb3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 14 Jul 2015 18:34:25 +0200 Subject: [PATCH 2/2] fixed broken test --- sapi/cli/tests/bug69655.phpt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sapi/cli/tests/bug69655.phpt b/sapi/cli/tests/bug69655.phpt index 188b9c31eeaa9..73791c95d589d 100644 --- a/sapi/cli/tests/bug69655.phpt +++ b/sapi/cli/tests/bug69655.phpt @@ -10,7 +10,7 @@ include "skipif.inc"; ['method' => $method]]); // the following is supposed to emit a warning for unsupported methods file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context); @@ -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