1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-09-29 04:25:57 -04: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_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;
}
parser->req_type = httpp_str_to_method(req_type);
if (uri != NULL && strlen(uri) > 0) {
char *query;
@ -569,3 +553,23 @@ static int _free_vars(void *key)
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

@ -82,5 +82,8 @@ void httpp_set_query_param(http_parser_t *parser, const char *name, const char *
const char *httpp_get_query_param(http_parser_t *parser, const char *name);
void httpp_destroy(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