10000 Added support for "SUBSCRIBE" and "UNSUBSCRIBE" request methods. · zwxalgorithm/http-parser@f825b52 · GitHub
[go: up one dir, main page]

Skip to content

Commit f825b52

Browse files
TooTallNatery
authored andcommitted
Added support for "SUBSCRIBE" and "UNSUBSCRIBE" request methods.
1 parent d56a070 commit f825b52

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

http_parser.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ static const char *method_strings[] =
9595
, "MERGE"
9696
, "M-SEARCH"
9797
, "NOTIFY"
98+
, "SUBSCRIBE"
99+
, "UNSUBSCRIBE"
98100
};
99101

100102

@@ -582,8 +584,9 @@ size_t http_parser_execute (http_parser *parser,
582584
case 'O': parser->method = HTTP_OPTIONS; break;
583585
case 'P': parser->method = HTTP_POST; /* or PROPFIND or PROPPATCH or PUT */ break;
584586
case 'R': parser->method = HTTP_REPORT; break;
587+
case 'S': parser->method = HTTP_SUBSCRIBE; break;
585588
case 'T': parser->method = HTTP_TRACE; break;
586-
case 'U': parser->method = HTTP_UNLOCK; break;
589+
case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
587590
default: goto error;
588591
}
589592
state = s_req_method;
@@ -620,6 +623,8 @@ size_t http_parser_execute (http_parser *parser,
620623
parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */
621624
} else if (index == 1 && parser->method == HTTP_POST && ch == 'U') {
622625
parser->method = HTTP_PUT;
626+
} else if (index == 2 && parser->method == HTTP_UNLOCK && ch == 'S') {
627+
parser->method = HTTP_UNSUBSCRIBE;
623628
} else if (index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') {
624629
parser->method = HTTP_PROPPATCH;
625630
} else {

http_parser.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ enum http_method
101101
, HTTP_MKACTIVITY
102102
, HTTP_CHECKOUT
103103
, HTTP_MERGE
104-
/* ssdp */
104+
/* upnp */
105105
, HTTP_MSEARCH
106106
, HTTP_NOTIFY
107+
, HTTP_SUBSCRIBE
108+
, HTTP_UNSUBSCRIBE
107109
};
108110

109111

0 commit comments

Comments
 (0)
0