diff --git a/http_parser.c b/http_parser.c index f2ca661..ac41fed 100644 --- a/http_parser.c +++ b/http_parser.c @@ -137,6 +137,7 @@ static const char *method_strings[] = , "MOVE" , "PROPFIND" , "PROPPATCH" + , "SEARCH" , "UNLOCK" , "REPORT" , "MKACTIVITY" @@ -918,7 +919,7 @@ size_t http_parser_execute (http_parser *parser, /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ break; case 'R': parser->method = HTTP_REPORT; break; - case 'S': parser->method = HTTP_SUBSCRIBE; break; + case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break; case 'T': parser->method = HTTP_TRACE; break; case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; default: @@ -965,6 +966,12 @@ size_t http_parser_execute (http_parser *parser, } else { goto error; } + } else if (parser->method == HTTP_SUBSCRIBE) { + if (parser->index == 1 && ch == 'E') { + parser->method = HTTP_SEARCH; + } else { + goto error; + } } else if (parser->index == 1 && parser->method == HTTP_POST) { if (ch == 'R') { parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ diff --git a/http_parser.h b/http_parser.h index ae62661..b833acb 100644 --- a/http_parser.h +++ b/http_parser.h @@ -102,20 +102,21 @@ typedef int (*http_cb) (http_parser*); XX(11, MOVE) \ XX(12, PROPFIND) \ XX(13, PROPPATCH) \ - XX(14, UNLOCK) \ + XX(14, SEARCH) \ + XX(15, UNLOCK) \ /* subversion */ \ - XX(15, REPORT) \ - XX(16, MKACTIVITY) \ - XX(17, CHECKOUT) \ - XX(18, MERGE) \ + XX(16, REPORT) \ + XX(17, MKACTIVITY) \ + XX(18, CHECKOUT) \ + XX(19, MERGE) \ /* upnp */ \ - XX(19, MSEARCH) \ - XX(20, NOTIFY) \ - XX(21, SUBSCRIBE) \ - XX(22, UNSUBSCRIBE) \ + XX(20, MSEARCH) \ + XX(21, NOTIFY) \ + XX(22, SUBSCRIBE) \ + XX(23, UNSUBSCRIBE) \ /* RFC-5789 */ \ - XX(23, PATCH) \ - XX(24, PURGE) \ + XX(24, PATCH) \ + XX(25, PURGE) \ enum http_method { diff --git a/test.c b/test.c index e0ffd4d..db4fc32 100644 --- a/test.c +++ b/test.c @@ -850,6 +850,26 @@ const struct message requests[] = ,.body= "" } +#define SEARCH_REQ 32 +, {.name = "SEARCH request" + ,.type= HTTP_REQUEST + ,.raw= "SEARCH / HTTP/1.1\r\n" + "Host: www.example.com\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_SEARCH + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 1 + ,.headers= { { "Host", "www.example.com" } } + ,.body= "" + } + , {.name= NULL } /* sentinel */ };