From ce10725a5eface100117aa26d3a2b60d536b0cae Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 24 Apr 2015 17:36:26 +0200 Subject: [PATCH 1/3] Support BIND (WebDAV, RFC5842, Section 4). --- http_parser.c | 1 + http_parser.h | 27 +++++++++++++++------------ test.c | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/http_parser.c b/http_parser.c index 0fa1c362..79740c29 100644 --- a/http_parser.c +++ b/http_parser.c @@ -957,6 +957,7 @@ size_t http_parser_execute (http_parser *parser, parser->method = (enum http_method) 0; parser->index = 1; switch (ch) { + case 'B': parser->method = HTTP_BIND; break; case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; case 'D': parser->method = HTTP_DELETE; break; case 'G': parser->method = HTTP_GET; break; diff --git a/http_parser.h b/http_parser.h index eb71bf99..0a76f452 100644 --- a/http_parser.h +++ b/http_parser.h @@ -95,7 +95,7 @@ typedef int (*http_cb) (http_parser*); XX(5, CONNECT, CONNECT) \ XX(6, OPTIONS, OPTIONS) \ XX(7, TRACE, TRACE) \ - /* webdav */ \ + /* WebDAV */ \ XX(8, COPY, COPY) \ XX(9, LOCK, LOCK) \ XX(10, MKCOL, MKCOL) \ @@ -104,21 +104,24 @@ typedef int (*http_cb) (http_parser*); XX(13, PROPPATCH, PROPPATCH) \ XX(14, SEARCH, SEARCH) \ XX(15, UNLOCK, UNLOCK) \ + XX(16, BIND, BIND) \ + XX(17, REBIND, REBIND) \ + XX(18, UNBIND, UNBIND) \ /* subversion */ \ - XX(16, REPORT, REPORT) \ - XX(17, MKACTIVITY, MKACTIVITY) \ - XX(18, CHECKOUT, CHECKOUT) \ - XX(19, MERGE, MERGE) \ + XX(19, REPORT, REPORT) \ + XX(20, MKACTIVITY, MKACTIVITY) \ + XX(21, CHECKOUT, CHECKOUT) \ + XX(22, MERGE, MERGE) \ /* upnp */ \ - XX(20, MSEARCH, M-SEARCH) \ - XX(21, NOTIFY, NOTIFY) \ - XX(22, SUBSCRIBE, SUBSCRIBE) \ - XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ + XX(23, MSEARCH, M-SEARCH) \ + XX(24, NOTIFY, NOTIFY) \ + XX(25, SUBSCRIBE, SUBSCRIBE) \ + XX(26, UNSUBSCRIBE, UNSUBSCRIBE) \ /* RFC-5789 */ \ - XX(24, PATCH, PATCH) \ - XX(25, PURGE, PURGE) \ + XX(27, PATCH, PATCH) \ + XX(28, PURGE, PURGE) \ /* CalDAV */ \ - XX(26, MKCALENDAR, MKCALENDAR) \ + XX(29, MKCALENDAR, MKCALENDAR) \ enum http_method { diff --git a/test.c b/test.c index 4c00571e..c192b2c7 100644 --- a/test.c +++ b/test.c @@ -3691,6 +3691,7 @@ main (void) "PROPFIND", "PROPPATCH", "UNLOCK", + "BIND", "REPORT", "MKACTIVITY", "CHECKOUT", From 2a8159fe1ab2cbb77f5591c834fd1092612ef6f8 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 24 Apr 2015 17:43:14 +0200 Subject: [PATCH 2/3] Support REBIND (WebDAV, RFC5842, Section 6). --- http_parser.c | 9 ++++++++- test.c | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/http_parser.c b/http_parser.c index 79740c29..ba96188c 100644 --- a/http_parser.c +++ b/http_parser.c @@ -969,7 +969,7 @@ size_t http_parser_execute (http_parser *parser, case 'P': parser->method = HTTP_POST; /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ 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 'T': parser->method = HTTP_TRACE; break; case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; @@ -1028,6 +1028,13 @@ size_t http_parser_execute (http_parser *parser, SET_ERRNO(HPE_INVALID_METHOD); 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) { if (ch == 'R') { parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ diff --git a/test.c b/test.c index c192b2c7..25e7aa8c 100644 --- a/test.c +++ b/test.c @@ -3692,6 +3692,7 @@ main (void) "PROPPATCH", "UNLOCK", "BIND", + "REBIND", "REPORT", "MKACTIVITY", "CHECKOUT", From 64367eb0cb1500f15d2df33ccb2f4440f96577e5 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 24 Apr 2015 17:46:13 +0200 Subject: [PATCH 3/3] Support UNBIND (WebDAV, RFC5842, Section 5). --- http_parser.c | 4 +++- test.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/http_parser.c b/http_parser.c index ba96188c..159279cb 100644 --- a/http_parser.c +++ b/http_parser.c @@ -972,7 +972,7 @@ size_t http_parser_execute (http_parser *parser, case 'R': parser->method = HTTP_REPORT; /* or REBIND */ 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; + case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE, UNBIND */ break; default: SET_ERRNO(HPE_INVALID_METHOD); goto error; @@ -1057,6 +1057,8 @@ size_t http_parser_execute (http_parser *parser, } else if (parser->method == HTTP_UNLOCK) { if (ch == 'S') { parser->method = HTTP_UNSUBSCRIBE; + } else if(ch == 'B') { + parser->method = HTTP_UNBIND; } else { SET_ERRNO(HPE_INVALID_METHOD); goto error; diff --git a/test.c b/test.c index 25e7aa8c..51e380e6 100644 --- a/test.c +++ b/test.c @@ -3693,6 +3693,7 @@ main (void) "UNLOCK", "BIND", "REBIND", + "UNBIND", "REPORT", "MKACTIVITY", "CHECKOUT",