Renamed http strict and not strict

This commit is contained in:
2020-12-16 18:43:53 +01:00
parent 1be4929c6c
commit 812d5ab384
3 changed files with 6 additions and 6 deletions

View File

@ -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.");

View File

@ -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;

View File

@ -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;