add support for "SEARCH" request methods

v0.10
Nathan Rajlich 13 years ago committed by Ben Noordhuis
parent 5a1e556239
commit a3373d7627

@ -137,6 +137,7 @@ static const char *method_strings[] =
, "MOVE" , "MOVE"
, "PROPFIND" , "PROPFIND"
, "PROPPATCH" , "PROPPATCH"
, "SEARCH"
, "UNLOCK" , "UNLOCK"
, "REPORT" , "REPORT"
, "MKACTIVITY" , "MKACTIVITY"
@ -918,7 +919,7 @@ size_t http_parser_execute (http_parser *parser,
/* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */
break; break;
case 'R': parser->method = HTTP_REPORT; 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 'T': parser->method = HTTP_TRACE; break;
case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
default: default:
@ -965,6 +966,12 @@ size_t http_parser_execute (http_parser *parser,
} else { } else {
goto error; 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) { } else if (parser->index == 1 && parser->method == HTTP_POST) {
if (ch == 'R') { if (ch == 'R') {
parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */

@ -102,20 +102,21 @@ typedef int (*http_cb) (http_parser*);
XX(11, MOVE) \ XX(11, MOVE) \
XX(12, PROPFIND) \ XX(12, PROPFIND) \
XX(13, PROPPATCH) \ XX(13, PROPPATCH) \
XX(14, UNLOCK) \ XX(14, SEARCH) \
XX(15, UNLOCK) \
/* subversion */ \ /* subversion */ \
XX(15, REPORT) \ XX(16, REPORT) \
XX(16, MKACTIVITY) \ XX(17, MKACTIVITY) \
XX(17, CHECKOUT) \ XX(18, CHECKOUT) \
XX(18, MERGE) \ XX(19, MERGE) \
/* upnp */ \ /* upnp */ \
XX(19, MSEARCH) \ XX(20, MSEARCH) \
XX(20, NOTIFY) \ XX(21, NOTIFY) \
XX(21, SUBSCRIBE) \ XX(22, SUBSCRIBE) \
XX(22, UNSUBSCRIBE) \ XX(23, UNSUBSCRIBE) \
/* RFC-5789 */ \ /* RFC-5789 */ \
XX(23, PATCH) \ XX(24, PATCH) \
XX(24, PURGE) \ XX(25, PURGE) \
enum http_method enum http_method
{ {

@ -850,6 +850,26 @@ const struct message requests[] =
,.body= "" ,.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 */ , {.name= NULL } /* sentinel */
}; };

Loading…
Cancel
Save