From 27542db4e70c388346fc9983b9c7d58248aaa52d Mon Sep 17 00:00:00 2001 From: Niklas Lindgren Date: Wed, 12 Sep 2012 19:34:59 +0300 Subject: Respond with 501 to unknown request methods Fixed typo Moved 501 response from dispatch to event_read_request Return return value of send_error_page --- sapi/cli/php_http_parser.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sapi/cli/php_http_parser.c') diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index 13b9ea12bc..4a95f82575 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -99,6 +99,7 @@ static const char *method_strings[] = , "NOTIFY" , "SUBSCRIBE" , "UNSUBSCRIBE" + , "NOTIMPLEMENTED" }; @@ -589,7 +590,7 @@ size_t php_http_parser_execute (php_http_parser *parser, case 'S': parser->method = PHP_HTTP_SUBSCRIBE; break; case 'T': parser->method = PHP_HTTP_TRACE; break; case 'U': parser->method = PHP_HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; - default: goto error; + default: parser->method = PHP_HTTP_NOT_IMPLEMENTED; break; } state = s_req_method; break; @@ -602,7 +603,7 @@ size_t php_http_parser_execute (php_http_parser *parser, goto error; matcher = method_strings[parser->method]; - if (ch == ' ' && matcher[index] == '\0') { + if (ch == ' ' && (matcher[index] == '\0' || parser->method == PHP_HTTP_NOT_IMPLEMENTED)) { state = s_req_spaces_before_url; } else if (ch == matcher[index]) { ; /* nada */ @@ -631,7 +632,7 @@ size_t php_http_parser_execute (php_http_parser *parser, } else if (index == 4 && parser->method == PHP_HTTP_PROPFIND && ch == 'P') { parser->method = PHP_HTTP_PROPPATCH; } else { - goto error; + parser->method = PHP_HTTP_NOT_IMPLEMENTED; } ++index; -- cgit v1.2.1 From aa133ea2821787c0cf4ac8750ddd22341752f135 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Tue, 18 Sep 2012 22:16:51 +0200 Subject: Merged GitHub PR #190: Support for the HTTP PATCH method in CLI webserver --- sapi/cli/php_http_parser.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sapi/cli/php_http_parser.c') diff --git a/sapi/cli/php_http_parser.c b/sapi/cli/php_http_parser.c index 4a95f82575..d3bc496f4e 100644 --- a/sapi/cli/php_http_parser.c +++ b/sapi/cli/php_http_parser.c @@ -81,6 +81,7 @@ static const char *method_strings[] = , "HEAD" , "POST" , "PUT" + , "PATCH" , "CONNECT" , "OPTIONS" , "TRACE" @@ -627,6 +628,8 @@ size_t php_http_parser_execute (php_http_parser *parser, parser->method = PHP_HTTP_PROPFIND; /* or HTTP_PROPPATCH */ } else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'U') { parser->method = PHP_HTTP_PUT; + } else if (index == 1 && parser->method == PHP_HTTP_POST && ch == 'A') { + parser->method = PHP_HTTP_PATCH; } else if (index == 2 && parser->method == PHP_HTTP_UNLOCK && ch == 'S') { parser->method = PHP_HTTP_UNSUBSCRIBE; } else if (index == 4 && parser->method == PHP_HTTP_PROPFIND && ch == 'P') { -- cgit v1.2.1