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"
, "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 */

@ -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
{

@ -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 */
};

Loading…
Cancel
Save