1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

expose converting of method names to enum values as httpp_str_to_method()

svn path=/icecast/trunk/httpp/; revision=19348
This commit is contained in:
Philipp Schafft 2014-11-22 04:44:47 +00:00
parent c5f549f1aa
commit 7572febbd8
2 changed files with 24 additions and 17 deletions

View File

@ -337,23 +337,7 @@ int httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len)
} }
} }
if (strcasecmp("GET", req_type) == 0) { parser->req_type = httpp_str_to_method(req_type);
parser->req_type = httpp_req_get;
} else if (strcasecmp("POST", req_type) == 0) {
parser->req_type = httpp_req_post;
} else if (strcasecmp("PUT", req_type) == 0) {
parser->req_type = httpp_req_put;
} else if (strcasecmp("HEAD", req_type) == 0) {
parser->req_type = httpp_req_head;
} else if (strcasecmp("SOURCE", req_type) == 0) {
parser->req_type = httpp_req_source;
} else if (strcasecmp("PLAY", req_type) == 0) {
parser->req_type = httpp_req_play;
} else if (strcasecmp("STATS", req_type) == 0) {
parser->req_type = httpp_req_stats;
} else {
parser->req_type = httpp_req_unknown;
}
if (uri != NULL && strlen(uri) > 0) { if (uri != NULL && strlen(uri) > 0) {
char *query; char *query;
@ -569,3 +553,23 @@ static int _free_vars(void *key)
return 1; return 1;
} }
httpp_request_type_e httpp_str_to_method(const char * method) {
if (strcasecmp("GET", method) == 0) {
return httpp_req_get;
} else if (strcasecmp("POST", method) == 0) {
return httpp_req_post;
} else if (strcasecmp("PUT", method) == 0) {
return httpp_req_put;
} else if (strcasecmp("HEAD", method) == 0) {
return httpp_req_head;
} else if (strcasecmp("SOURCE", method) == 0) {
return httpp_req_source;
} else if (strcasecmp("PLAY", method) == 0) {
return httpp_req_play;
} else if (strcasecmp("STATS", method) == 0) {
return httpp_req_stats;
} else {
return httpp_req_unknown;
}
}

View File

@ -83,4 +83,7 @@ const char *httpp_get_query_param(http_parser_t *parser, const char *name);
void httpp_destroy(http_parser_t *parser); void httpp_destroy(http_parser_t *parser);
void httpp_clear(http_parser_t *parser); void httpp_clear(http_parser_t *parser);
/* util functions */
httpp_request_type_e httpp_str_to_method(const char * method);
#endif #endif