mirror of
https://github.com/nodejs/http-parser.git
synced 2025-10-22 08:22:06 +08:00
Add support for "M-SEARCH" and "NOTIFY" request methods.
Allow a request path of "*" (for SSDP requests).
This commit is contained in:

committed by
Ryan Dahl

parent
03970a576d
commit
d56a0700d0
@@ -93,6 +93,8 @@ static const char *method_strings[] =
|
||||
, "MKACTIVITY"
|
||||
, "CHECKOUT"
|
||||
, "MERGE"
|
||||
, "M-SEARCH"
|
||||
, "NOTIFY"
|
||||
};
|
||||
|
||||
|
||||
@@ -575,7 +577,8 @@ size_t http_parser_execute (http_parser *parser,
|
||||
case 'G': parser->method = HTTP_GET; break;
|
||||
case 'H': parser->method = HTTP_HEAD; break;
|
||||
case 'L': parser->method = HTTP_LOCK; break;
|
||||
case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE */ break;
|
||||
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 'R': parser->method = HTTP_REPORT; break;
|
||||
@@ -608,6 +611,8 @@ size_t http_parser_execute (http_parser *parser,
|
||||
parser->method = HTTP_MOVE;
|
||||
} else if (index == 1 && ch == 'E') {
|
||||
parser->method = HTTP_MERGE;
|
||||
} else if (index == 1 && ch == '-') {
|
||||
parser->method = HTTP_MSEARCH;
|
||||
} else if (index == 2 && ch == 'A') {
|
||||
parser->method = HTTP_MKACTIVITY;
|
||||
}
|
||||
@@ -628,7 +633,7 @@ size_t http_parser_execute (http_parser *parser,
|
||||
{
|
||||
if (ch == ' ') break;
|
||||
|
||||
if (ch == '/') {
|
||||
if (ch == '/' || ch == '*') {
|
||||
MARK(url);
|
||||
MARK(path);
|
||||
state = s_req_path;
|
||||
|
@@ -101,6 +101,9 @@ enum http_method
|
||||
, HTTP_MKACTIVITY
|
||||
, HTTP_CHECKOUT
|
||||
, HTTP_MERGE
|
||||
/* ssdp */
|
||||
, HTTP_MSEARCH
|
||||
, HTTP_NOTIFY
|
||||
};
|
||||
|
||||
|
||||
|
25
test.c
25
test.c
@@ -557,6 +557,31 @@ const struct message requests[] =
|
||||
,.body= ""
|
||||
}
|
||||
|
||||
#define MSEARCH_REQ 19
|
||||
, {.name= "m-search request"
|
||||
,.type= HTTP_REQUEST
|
||||
,.raw= "M-SEARCH * HTTP/1.1\r\n"
|
||||
"HOST: 239.255.255.250:1900\r\n"
|
||||
"MAN: \"ssdp:discover\"\r\n"
|
||||
"ST: \"ssdp:all\"\r\n"
|
||||
"\r\n"
|
||||
,.should_keep_alive= TRUE
|
||||
,.message_complete_on_eof= FALSE
|
||||
,.http_major= 1
|
||||
,.http_minor= 1
|
||||
,.method= HTTP_MSEARCH
|
||||
,.query_string= ""
|
||||
,.fragment= ""
|
||||
,.request_path= "*"
|
||||
,.request_url= "*"
|
||||
,.num_headers= 3
|
||||
,.headers= { { "HOST", "239.255.255.250:1900" }
|
||||
, { "MAN", "\"ssdp:discover\"" }
|
||||
, { "ST", "\"ssdp:all\"" }
|
||||
}
|
||||
,.body= ""
|
||||
}
|
||||
|
||||
, {.name= NULL } /* sentinel */
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user