src: support BIND/REBIND/UNBIND (WebDAV, RFC5842)

Support BIND/REBIND/UNBIND methods, see sections 4, 5, 6 of
RFC5842.

PR-URL: https://github.com/joyent/http-parser/pull/242
Reviewed-By: Fedor Indutny <fedor@indutny.com>
make-http-max-header-size-gyp-configurable
Ivan Enderlin 10 years ago committed by Fedor Indutny
parent 7d75dd7325
commit 8b1d652322

@ -959,6 +959,7 @@ reexecute:
parser->method = (enum http_method) 0; parser->method = (enum http_method) 0;
parser->index = 1; parser->index = 1;
switch (ch) { switch (ch) {
case 'B': parser->method = HTTP_BIND; break;
case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break;
case 'D': parser->method = HTTP_DELETE; break; case 'D': parser->method = HTTP_DELETE; break;
case 'G': parser->method = HTTP_GET; break; case 'G': parser->method = HTTP_GET; break;
@ -970,10 +971,10 @@ reexecute:
case 'P': parser->method = HTTP_POST; case 'P': parser->method = HTTP_POST;
/* 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; /* or REBIND */ break;
case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ 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, UNBIND */ break;
default: default:
SET_ERRNO(HPE_INVALID_METHOD); SET_ERRNO(HPE_INVALID_METHOD);
goto error; goto error;
@ -1029,6 +1030,13 @@ reexecute:
SET_ERRNO(HPE_INVALID_METHOD); SET_ERRNO(HPE_INVALID_METHOD);
goto error; goto error;
} }
} else if (parser->method == HTTP_REPORT) {
if (parser->index == 2 && ch == 'B') {
parser->method = HTTP_REBIND;
} else {
SET_ERRNO(HPE_INVALID_METHOD);
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 */
@ -1051,6 +1059,8 @@ reexecute:
} else if (parser->method == HTTP_UNLOCK) { } else if (parser->method == HTTP_UNLOCK) {
if (ch == 'S') { if (ch == 'S') {
parser->method = HTTP_UNSUBSCRIBE; parser->method = HTTP_UNSUBSCRIBE;
} else if(ch == 'B') {
parser->method = HTTP_UNBIND;
} else { } else {
SET_ERRNO(HPE_INVALID_METHOD); SET_ERRNO(HPE_INVALID_METHOD);
goto error; goto error;

@ -95,7 +95,7 @@ typedef int (*http_cb) (http_parser*);
XX(5, CONNECT, CONNECT) \ XX(5, CONNECT, CONNECT) \
XX(6, OPTIONS, OPTIONS) \ XX(6, OPTIONS, OPTIONS) \
XX(7, TRACE, TRACE) \ XX(7, TRACE, TRACE) \
/* webdav */ \ /* WebDAV */ \
XX(8, COPY, COPY) \ XX(8, COPY, COPY) \
XX(9, LOCK, LOCK) \ XX(9, LOCK, LOCK) \
XX(10, MKCOL, MKCOL) \ XX(10, MKCOL, MKCOL) \
@ -104,21 +104,24 @@ typedef int (*http_cb) (http_parser*);
XX(13, PROPPATCH, PROPPATCH) \ XX(13, PROPPATCH, PROPPATCH) \
XX(14, SEARCH, SEARCH) \ XX(14, SEARCH, SEARCH) \
XX(15, UNLOCK, UNLOCK) \ XX(15, UNLOCK, UNLOCK) \
XX(16, BIND, BIND) \
XX(17, REBIND, REBIND) \
XX(18, UNBIND, UNBIND) \
/* subversion */ \ /* subversion */ \
XX(16, REPORT, REPORT) \ XX(19, REPORT, REPORT) \
XX(17, MKACTIVITY, MKACTIVITY) \ XX(20, MKACTIVITY, MKACTIVITY) \
XX(18, CHECKOUT, CHECKOUT) \ XX(21, CHECKOUT, CHECKOUT) \
XX(19, MERGE, MERGE) \ XX(22, MERGE, MERGE) \
/* upnp */ \ /* upnp */ \
XX(20, MSEARCH, M-SEARCH) \ XX(23, MSEARCH, M-SEARCH) \
XX(21, NOTIFY, NOTIFY) \ XX(24, NOTIFY, NOTIFY) \
XX(22, SUBSCRIBE, SUBSCRIBE) \ XX(25, SUBSCRIBE, SUBSCRIBE) \
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ XX(26, UNSUBSCRIBE, UNSUBSCRIBE) \
/* RFC-5789 */ \ /* RFC-5789 */ \
XX(24, PATCH, PATCH) \ XX(27, PATCH, PATCH) \
XX(25, PURGE, PURGE) \ XX(28, PURGE, PURGE) \
/* CalDAV */ \ /* CalDAV */ \
XX(26, MKCALENDAR, MKCALENDAR) \ XX(29, MKCALENDAR, MKCALENDAR) \
enum http_method enum http_method
{ {

@ -3744,6 +3744,9 @@ main (void)
"PROPFIND", "PROPFIND",
"PROPPATCH", "PROPPATCH",
"UNLOCK", "UNLOCK",
"BIND",
"REBIND",
"UNBIND",
"REPORT", "REPORT",
"MKACTIVITY", "MKACTIVITY",
"CHECKOUT", "CHECKOUT",

Loading…
Cancel
Save