Commit 7572febb authored by Philipp Schafft's avatar Philipp Schafft 🦁

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

svn path=/icecast/trunk/httpp/; revision=19348
parent c5f549f1
......@@ -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;
}
}
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment