added all methods to meta data parser + methodString-function

This commit is contained in:
overflowerror 2019-03-07 17:13:02 +01:00
parent 0e9e7473bd
commit c5376732ea
2 changed files with 41 additions and 0 deletions

View file

@ -186,10 +186,22 @@ int headers_metadata(struct metaData* metaData, char* header) {
if (strcmp(_method, "GET") == 0)
method = GET;
else if (strcmp(_method, "HEAD") == 0)
method = HEAD;
else if (strcmp(_method, "POST") == 0)
method = POST;
else if (strcmp(_method, "PUT") == 0)
method = PUT;
else if (strcmp(_method, "DELETE") == 0)
method = DELETE;
else if (strcmp(_method, "CONNECT") == 0)
method = CONNECT;
else if (strcmp(_method, "OPTION") == 0)
method = OPTION;
else if (strcmp(_method, "TRACE") == 0)
method = TRACE;
else if (strcmp(_method, "PATCH") == 0)
method = PATCH;
else
return HEADERS_PARSE_ERROR;
@ -220,3 +232,30 @@ int headers_metadata(struct metaData* metaData, char* header) {
return HEADERS_SUCCESS;
}
const char* methodString(struct metaData metaData) {
switch(metaData.method) {
case GET:
return "GET";
case HEAD:
return "HEAD";
case POST:
return "POST";
case POST:
return "POST";
case PUT:
return "PUT";
case DELETE:
return "DELETE";
case CONNECT:
return "CONNECT";
case OPTION:
return "OPTION";
case TRACE:
return "TRACE";
case PATCH:
return "PATCH";
default:
return NULL
}
}

View file

@ -29,4 +29,6 @@ void headers_dump(struct headers* headers, FILE* stream);
int headers_metadata(struct metaData* metaData, char* header);
const char* methodString(struct metaData metaData);
#endif