Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Commit cf0be24

Browse files
committed
methods: add link and unlink
LINK and UNLINK are registered methods and are in real world use.
1 parent e01811e commit cf0be24

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

http_parser.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ do { \
123123
FOR##_mark = NULL; \
124124
} \
125125
} while (0)
126-
126+
127127
/* Run the data callback FOR and consume the current byte */
128128
#define CALLBACK_DATA(FOR) \
129129
CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1)
@@ -1000,6 +1000,13 @@ size_t http_parser_execute (http_parser *parser,
10001000
UPDATE_STATE(s_req_spaces_before_url);
10011001
} else if (ch == matcher[parser->index]) {
10021002
; /* nada */
1003+
} else if (parser->method == HTTP_LOCK) {
1004+
if (parser->index == 1 && ch == 'I') {
1005+
parser->method = HTTP_LINK;
1006+
} else {
1007+
SET_ERRNO(HPE_INVALID_METHOD);
1008+
goto error;
1009+
}
10031010
} else if (parser->method == HTTP_CONNECT) {
10041011
if (parser->index == 1 && ch == 'H') {
10051012
parser->method = HTTP_CHECKOUT;
@@ -1070,6 +1077,13 @@ size_t http_parser_execute (http_parser *parser,
10701077
SET_ERRNO(HPE_INVALID_METHOD);
10711078
goto error;
10721079
}
1080+
} else if (parser->method == HTTP_UNLOCK && parser->index == 3) {
1081+
if (ch == 'I') {
1082+
parser->method = HTTP_UNLINK;
1083+
} else {
1084+
SET_ERRNO(HPE_INVALID_METHOD);
1085+
goto error;
1086+
}
10731087
} else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') {
10741088
parser->method = HTTP_PROPPATCH;
10751089
} else {

http_parser.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ typedef int (*http_cb) (http_parser*);
124124
XX(29, PURGE, PURGE) \
125125
/* CalDAV */ \
126126
XX(30, MKCALENDAR, MKCALENDAR) \
127+
/* RFC-7237 */ \
128+
XX(31, LINK, LINK) \
129+
XX(32, UNLINK, UNLINK)
127130

128131
enum http_method
129132
{
@@ -149,7 +152,7 @@ enum flags
149152

150153

151154
/* Map for errno-related constants
152-
*
155+
*
153156
* The provided argument should be a macro that takes 2 arguments.
154157
*/
155158
#define HTTP_ERRNO_MAP(XX) \

0 commit comments

Comments
 (0)