Expose http_method_str() to get a string version of a method

event_stream
Ryan Dahl 15 years ago
parent 9dc258f9dd
commit ddbd5c3728

@ -77,6 +77,29 @@ do { \
#define CLOSE "close"
static const char *method_strings[] =
{ "DELETE"
, "GET"
, "HEAD"
, "POST"
, "PUT"
, "CONNECT"
, "OPTIONS"
, "TRACE"
, "COPY"
, "LOCK"
, "MKCOL"
, "MOVE"
, "PROPFIND"
, "PROPPATCH"
, "UNLOCK"
, "REPORT"
, "MKACTIVITY"
, "CHECKOUT"
, "MERGE"
};
static const char lowcase[256] =
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0" "0123456789\0\0\0\0\0\0"
@ -527,28 +550,7 @@ size_t http_parser_execute (http_parser *parser,
if (ch == '\0')
goto error;
static const char *match_strs[] = {
"DELETE",
"GET",
"HEAD",
"POST",
"PUT",
"CONNECT",
"OPTIONS",
"TRACE",
"COPY",
"LOCK",
"MKCOL",
"MOVE",
"PROPFIND",
"PROPPATCH",
"UNLOCK",
"REPORT",
"MKACTIVITY",
"CHECKOUT",
"MERGE" };
const char *matcher = match_strs[parser->method];
const char *matcher = method_strings[parser->method];
if (ch == ' ' && matcher[index] == '\0') {
state = s_req_spaces_before_url;
} else if (ch == matcher[index]) {
@ -1520,6 +1522,12 @@ http_should_keep_alive (http_parser *parser)
}
const char * http_method_str (enum http_method m)
{
return method_strings[m];
}
void
http_parser_init (http_parser *parser, enum http_parser_type t)
{
@ -1528,4 +1536,3 @@ http_parser_init (http_parser *parser, enum http_parser_type t)
parser->nread = 0;
parser->upgrade = 0;
}

@ -154,6 +154,8 @@ size_t http_parser_execute(http_parser *parser,
*/
int http_should_keep_alive(http_parser *parser);
/* Returns a string version of the HTTP method. */
const char *http_method_str(enum http_method);
#ifdef __cplusplus
}

Loading…
Cancel
Save