diff --git a/src/client.c b/src/client.c index 50368ce..6828400 100644 --- a/src/client.c +++ b/src/client.c @@ -79,9 +79,9 @@ int client_request_handler(sock *client, int req_num) { goto respond; } - hdr_connection = http_get_header_field(&req.hdr, "Connection", HTTP_NOT_STRICT); + hdr_connection = http_get_header_field(&req.hdr, "Connection", HTTP_LOWER); client_keep_alive = hdr_connection != NULL && strncmp(hdr_connection, "keep-alive", 10) == 0; - host = http_get_header_field(&req.hdr, "Host", HTTP_NOT_STRICT); + host = http_get_header_field(&req.hdr, "Host", HTTP_LOWER); if (host == NULL || strchr(host, '/') != NULL) { res.status = http_get_status(400); sprintf(err_msg, "The client provided no or an invalid Host header field."); diff --git a/src/http.c b/src/http.c index 35a3aa7..84c3c1b 100644 --- a/src/http.c +++ b/src/http.c @@ -16,7 +16,7 @@ void http_to_camel_case(char *str, int strict) { ch = str[i]; if (last == '-' && ch >= 'a' && ch <= 'z') { str[i] = (char) ((int) ch & 0x5F); - } else if (last != '-' && ch >= 'A' && ch <= 'Z' && strict == HTTP_STRICT) { + } else if (last != '-' && ch >= 'A' && ch <= 'Z' && strict == HTTP_LOWER) { str[i] = (char) ((int) ch | 0x20); } last = str[i]; @@ -132,7 +132,7 @@ int http_receive_request(sock *client, http_req *req) { len = pos1 - ptr; req->hdr.fields[req->hdr.field_num][0] = malloc(len + 1); sprintf(req->hdr.fields[req->hdr.field_num][0], "%.*s", (int) len, ptr); - http_to_camel_case(req->hdr.fields[req->hdr.field_num][0], HTTP_NOT_STRICT); + http_to_camel_case(req->hdr.fields[req->hdr.field_num][0], HTTP_LOWER); pos1++; pos2 = pos0 - 1; diff --git a/src/http.h b/src/http.h index da19bad..2dc5ccf 100644 --- a/src/http.h +++ b/src/http.h @@ -8,8 +8,8 @@ #ifndef NECRONDA_SERVER_HTTP_H #define NECRONDA_SERVER_HTTP_H -#define HTTP_STRICT 1 -#define HTTP_NOT_STRICT 0 +#define HTTP_LOWER 1 +#define HTTP_PRESERVE_UPPER 0 typedef struct { unsigned short code;