diff --git a/http_parser.c b/http_parser.c index cf64841..1453d41 100644 --- a/http_parser.c +++ b/http_parser.c @@ -100,6 +100,7 @@ static const char *method_strings[] = , "NOTIFY" , "SUBSCRIBE" , "UNSUBSCRIBE" + , "PATCH" }; @@ -601,7 +602,9 @@ size_t http_parser_execute (http_parser *parser, case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH */ break; case 'N': parser->method = HTTP_NOTIFY; break; case 'O': parser->method = HTTP_OPTIONS; break; - case 'P': parser->method = HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break; + case 'P': parser->method = HTTP_POST; + /* or PROPFIND or PROPPATCH or PUT or PATCH */ + break; case 'R': parser->method = HTTP_REPORT; break; case 'S': parser->method = HTTP_SUBSCRIBE; break; case 'T': parser->method = HTTP_TRACE; break; @@ -642,6 +645,8 @@ size_t http_parser_execute (http_parser *parser, parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ } else if (index == 1 && parser->method == HTTP_POST && ch == 'U') { parser->method = HTTP_PUT; + } else if (index == 1 && parser->method == HTTP_POST && ch == 'A') { + parser->method = HTTP_PATCH; } else if (index == 2 && parser->method == HTTP_UNLOCK && ch == 'S') { parser->method = HTTP_UNSUBSCRIBE; } else if (index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') { diff --git a/http_parser.h b/http_parser.h index b30a74f..6a54a2d 100644 --- a/http_parser.h +++ b/http_parser.h @@ -106,6 +106,8 @@ enum http_method , HTTP_NOTIFY , HTTP_SUBSCRIBE , HTTP_UNSUBSCRIBE + /* RFC-5789 */ + , HTTP_PATCH }; diff --git a/test.c b/test.c index 7e2b210..a4b80a2 100644 --- a/test.c +++ b/test.c @@ -686,6 +686,35 @@ const struct message requests[] = } #endif /* !HTTP_PARSER_STRICT */ +#define PATCH_REQ 26 +, {.name = "PATCH request" + ,.type= HTTP_REQUEST + ,.raw= "PATCH /file.txt HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "Content-Type: application/example\r\n" + "If-Match: \"e0023aa4e\"\r\n" + "Content-Length: 10\r\n" + "\r\n" + "cccccccccc" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_PATCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/file.txt" + ,.request_url= "/file.txt" + ,.num_headers= 4 + ,.upgrade=0 + ,.headers= { { "Host", "www.example.com" } + , { "Content-Type", "application/example" } + , { "If-Match", "\"e0023aa4e\"" } + , { "Content-Length", "10" } + } + ,.body= "cccccccccc" + } + , {.name= NULL } /* sentinel */ };