Rename REQ_MOD to REQ_IF_MODIFIED_SINCE

The named constants for header fields of the response struct all
pretty much matched the actual header name, which I think improves
readability for everyone familiar with the HTTP-spec.

The request header fields named constants followed the rule, except
the "If-Modified-Since"-header, which is addressed in this commit.

Signed-off-by: Laslo Hunhold <dev@frign.de>
This commit is contained in:
Laslo Hunhold 2020-08-05 15:46:03 +02:00
parent 2c50d0c654
commit 90d5179ea0
No known key found for this signature in database
GPG key ID: 69576BD24CFCB980
2 changed files with 7 additions and 6 deletions

7
http.c
View file

@ -24,7 +24,7 @@
const char *req_field_str[] = { const char *req_field_str[] = {
[REQ_HOST] = "Host", [REQ_HOST] = "Host",
[REQ_RANGE] = "Range", [REQ_RANGE] = "Range",
[REQ_MOD] = "If-Modified-Since", [REQ_IF_MODIFIED_SINCE] = "If-Modified-Since",
}; };
const char *req_method_str[] = { const char *req_method_str[] = {
@ -671,9 +671,10 @@ http_send_response(int fd, struct request *req)
} }
/* modified since */ /* modified since */
if (req->field[REQ_MOD][0]) { if (req->field[REQ_IF_MODIFIED_SINCE][0]) {
/* parse field */ /* parse field */
if (!strptime(req->field[REQ_MOD], "%a, %d %b %Y %T GMT", &tm)) { if (!strptime(req->field[REQ_IF_MODIFIED_SINCE],
"%a, %d %b %Y %T GMT", &tm)) {
return http_send_status(fd, S_BAD_REQUEST); return http_send_status(fd, S_BAD_REQUEST);
} }

2
http.h
View file

@ -10,7 +10,7 @@
enum req_field { enum req_field {
REQ_HOST, REQ_HOST,
REQ_RANGE, REQ_RANGE,
REQ_MOD, REQ_IF_MODIFIED_SINCE,
NUM_REQ_FIELDS, NUM_REQ_FIELDS,
}; };