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

Commit

Permalink
Add subversion request methods
Browse files Browse the repository at this point in the history
REPORT, MKACTIVITY, CHECKOUT, MERGE
  • Loading branch information
ry committed Jun 24, 2010
1 parent 6533f8a commit 9dc258f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
42 changes: 29 additions & 13 deletions http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,15 @@ size_t http_parser_execute (http_parser *parser,
parser->method = (enum http_method) 0;
index = 1;
switch (ch) {
case 'C': parser->method = HTTP_CONNECT; /* or COPY */ 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;
case 'H': parser->method = HTTP_HEAD; break;
case 'L': parser->method = HTTP_LOCK; break;
case 'M': parser->method = HTTP_MKCOL; /* or MOVE */ break;
case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE */ 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;
case 'T': parser->method = HTTP_TRACE; break;
case 'U': parser->method = HTTP_UNLOCK; break;
default: goto error;
Expand Down Expand Up @@ -541,25 +542,40 @@ size_t http_parser_execute (http_parser *parser,
"MOVE",
"PROPFIND",
"PROPPATCH",
"UNLOCK" };
"UNLOCK",
"REPORT",
"MKACTIVITY",
"CHECKOUT",
"MERGE" };

const char *matcher = match_strs[parser->method];
if (ch == ' ' && matcher[index] == '\0')
if (ch == ' ' && matcher[index] == '\0') {
state = s_req_spaces_before_url;
else if (ch == matcher[index])
} else if (ch == matcher[index]) {
; // nada
else if (index == 2 && parser->method == HTTP_CONNECT && ch == 'P')
parser->method = HTTP_COPY;
else if (index == 1 && parser->method == HTTP_MKCOL && ch == 'O')
parser->method = HTTP_MOVE;
else if (index == 1 && parser->method == HTTP_POST && ch == 'R')
} else if (parser->method == HTTP_CONNECT) {
if (index == 1 && ch == 'H') {
parser->method = HTTP_CHECKOUT;
} else if (index == 2 && ch == 'P') {
parser->method = HTTP_COPY;
}
} else if (parser->method == HTTP_MKCOL) {
if (index == 1 && ch == 'O') {
parser->method = HTTP_MOVE;
} else if (index == 1 && ch == 'E') {
parser->method = HTTP_MERGE;
} else if (index == 2 && ch == 'A') {
parser->method = HTTP_MKACTIVITY;
}
} else if (index == 1 && parser->method == HTTP_POST && ch == 'R') {
parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */
else if (index == 1 && parser->method == HTTP_POST && ch == 'U')
} else if (index == 1 && parser->method == HTTP_POST && ch == 'U') {
parser->method = HTTP_PUT;
else if (index == 4 && parser->method == HTTP_PROPFIND && ch == 'P')
} else if (index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') {
parser->method = HTTP_PROPPATCH;
else
} else {
goto error;
}

++index;
break;
Expand Down
5 changes: 5 additions & 0 deletions http_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ enum http_method
, HTTP_PROPFIND
, HTTP_PROPPATCH
, HTTP_UNLOCK
/* subversion */
, HTTP_REPORT
, HTTP_MKACTIVITY
, HTTP_CHECKOUT
, HTTP_MERGE
};


Expand Down
19 changes: 19 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,25 @@ const struct message requests[] =
,.body= ""
}

#define REPORT_REQ 18
, {.name= "report request"
,.type= HTTP_REQUEST
,.raw= "REPORT /test HTTP/1.1\r\n"
"\r\n"
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_REPORT
,.query_string= ""
,.fragment= ""
,.request_path= "/test"
,.request_url= "/test"
,.num_headers= 0
,.headers= {}
,.body= ""
}

, {.name= NULL } /* sentinel */
};

Expand Down

0 comments on commit 9dc258f

Please sign in to comment.