mirror of
https://github.com/sigmasternchen/CFloor
synced 2025-03-15 12:28:53 +00:00
changed http version to protocol
This commit is contained in:
parent
20d6ff66c1
commit
8cbbd9a40a
3 changed files with 22 additions and 10 deletions
|
@ -166,8 +166,8 @@ int headers_metadata(struct metaData* metaData, char* header) {
|
|||
char* _path = strtok(NULL, " ");
|
||||
if (_path == NULL)
|
||||
return HEADERS_PARSE_ERROR;
|
||||
char* _httpVersion = strtok(NULL, " ");
|
||||
if (_httpVersion == NULL)
|
||||
char* _protocol = strtok(NULL, " ");
|
||||
if (_protocol == NULL)
|
||||
return HEADERS_PARSE_ERROR;
|
||||
|
||||
char* _null = strtok(NULL, " ");
|
||||
|
@ -205,11 +205,11 @@ int headers_metadata(struct metaData* metaData, char* header) {
|
|||
else
|
||||
return HEADERS_PARSE_ERROR;
|
||||
|
||||
enum httpVersion httpVersion;
|
||||
if (strcmp(_httpVersion, "HTTP/1.0") == 0)
|
||||
httpVersion = HTTP10;
|
||||
else if (strcmp(_httpVersion, "HTTP/1.1") == 0)
|
||||
httpVersion = HTTP11;
|
||||
enum protocol protocol;
|
||||
if (strcmp(_protocol, "HTTP/1.0") == 0)
|
||||
protocol = HTTP10;
|
||||
else if (strcmp(_protocol, "HTTP/1.1") == 0)
|
||||
protocol = HTTP11;
|
||||
else
|
||||
return HEADERS_PARSE_ERROR;
|
||||
|
||||
|
@ -236,7 +236,7 @@ int headers_metadata(struct metaData* metaData, char* header) {
|
|||
strcat(uri, queryString);
|
||||
|
||||
metaData->method = method;
|
||||
metaData->httpVersion = httpVersion;
|
||||
metaData->protocol = protocol;
|
||||
metaData->path = path;
|
||||
metaData->queryString = queryString;
|
||||
metaData->uri = uri;
|
||||
|
@ -268,3 +268,14 @@ const char* methodString(struct metaData metaData) {
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char* protocolString(struct metaData metaData) {
|
||||
switch(metaData.protocol) {
|
||||
case HTTP10:
|
||||
return "HTTP/1.0";
|
||||
case HTTP11:
|
||||
return "HTTP/1.1";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,5 +30,6 @@ void headers_dump(struct headers* headers, FILE* stream);
|
|||
int headers_metadata(struct metaData* metaData, char* header);
|
||||
|
||||
const char* methodString(struct metaData metaData);
|
||||
const char* protocolString(struct metaData metaData);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,13 +11,13 @@ enum method {
|
|||
GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH
|
||||
};
|
||||
|
||||
enum httpVersion {
|
||||
enum protocol {
|
||||
HTTP10, HTTP11
|
||||
};
|
||||
|
||||
struct metaData {
|
||||
enum method method;
|
||||
enum httpVersion httpVersion;
|
||||
enum protocol protocol;
|
||||
char* path;
|
||||
char* queryString;
|
||||
char* uri;
|
||||
|
|
Loading…
Reference in a new issue