[core] improve http_headers[] data struct packing

personal/stbuehler/ci-build
Glenn Strauss 3 years ago
parent 7e5dfc1a40
commit 5718a471b0
  1. 59
      src/http_header.c

@ -8,41 +8,42 @@
typedef struct keyvlenvalue {
const int key;
const unsigned int vlen;
const char * const value;
const size_t vlen;
} keyvlenvalue;
/* Note: must be sorted by length */
/* Note: must be kept in sync with http_header.h enum http_header_e */
#define CONST_LEN_STR(x) (unsigned int)(sizeof(x)-1), (x)
static const keyvlenvalue http_headers[] = {
{ HTTP_HEADER_HOST, CONST_STR_LEN("Host") }
,{ HTTP_HEADER_DATE, CONST_STR_LEN("Date") }
,{ HTTP_HEADER_ETAG, CONST_STR_LEN("ETag") }
,{ HTTP_HEADER_VARY, CONST_STR_LEN("Vary") }
,{ HTTP_HEADER_RANGE, CONST_STR_LEN("Range") }
,{ HTTP_HEADER_COOKIE, CONST_STR_LEN("Cookie") }
,{ HTTP_HEADER_EXPECT, CONST_STR_LEN("Expect") }
,{ HTTP_HEADER_STATUS, CONST_STR_LEN("Status") }
,{ HTTP_HEADER_SERVER, CONST_STR_LEN("Server") }
,{ HTTP_HEADER_UPGRADE, CONST_STR_LEN("Upgrade") }
,{ HTTP_HEADER_LOCATION, CONST_STR_LEN("Location") }
,{ HTTP_HEADER_FORWARDED, CONST_STR_LEN("Forwarded") }
,{ HTTP_HEADER_CONNECTION, CONST_STR_LEN("Connection") }
,{ HTTP_HEADER_SET_COOKIE, CONST_STR_LEN("Set-Cookie") }
,{ HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type") }
,{ HTTP_HEADER_LAST_MODIFIED, CONST_STR_LEN("Last-Modified") }
,{ HTTP_HEADER_AUTHORIZATION, CONST_STR_LEN("Authorization") }
,{ HTTP_HEADER_IF_NONE_MATCH, CONST_STR_LEN("If-None-Match") }
,{ HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control") }
,{ HTTP_HEADER_CONTENT_LENGTH, CONST_STR_LEN("Content-Length") }
,{ HTTP_HEADER_ACCEPT_ENCODING, CONST_STR_LEN("Accept-Encoding") }
,{ HTTP_HEADER_X_FORWARDED_FOR, CONST_STR_LEN("X-Forwarded-For") }
,{ HTTP_HEADER_CONTENT_ENCODING, CONST_STR_LEN("Content-Encoding") }
,{ HTTP_HEADER_CONTENT_LOCATION, CONST_STR_LEN("Content-Location") }
,{ HTTP_HEADER_IF_MODIFIED_SINCE, CONST_STR_LEN("If-Modified-Since") }
,{ HTTP_HEADER_TRANSFER_ENCODING, CONST_STR_LEN("Transfer-Encoding") }
,{ HTTP_HEADER_X_FORWARDED_PROTO, CONST_STR_LEN("X-Forwarded-Proto") }
,{ HTTP_HEADER_OTHER, NULL, 0 }
{ HTTP_HEADER_HOST, CONST_LEN_STR("Host") }
,{ HTTP_HEADER_DATE, CONST_LEN_STR("Date") }
,{ HTTP_HEADER_ETAG, CONST_LEN_STR("ETag") }
,{ HTTP_HEADER_VARY, CONST_LEN_STR("Vary") }
,{ HTTP_HEADER_RANGE, CONST_LEN_STR("Range") }
,{ HTTP_HEADER_COOKIE, CONST_LEN_STR("Cookie") }
,{ HTTP_HEADER_EXPECT, CONST_LEN_STR("Expect") }
,{ HTTP_HEADER_STATUS, CONST_LEN_STR("Status") }
,{ HTTP_HEADER_SERVER, CONST_LEN_STR("Server") }
,{ HTTP_HEADER_UPGRADE, CONST_LEN_STR("Upgrade") }
,{ HTTP_HEADER_LOCATION, CONST_LEN_STR("Location") }
,{ HTTP_HEADER_FORWARDED, CONST_LEN_STR("Forwarded") }
,{ HTTP_HEADER_CONNECTION, CONST_LEN_STR("Connection") }
,{ HTTP_HEADER_SET_COOKIE, CONST_LEN_STR("Set-Cookie") }
,{ HTTP_HEADER_CONTENT_TYPE, CONST_LEN_STR("Content-Type") }
,{ HTTP_HEADER_LAST_MODIFIED, CONST_LEN_STR("Last-Modified") }
,{ HTTP_HEADER_AUTHORIZATION, CONST_LEN_STR("Authorization") }
,{ HTTP_HEADER_IF_NONE_MATCH, CONST_LEN_STR("If-None-Match") }
,{ HTTP_HEADER_CACHE_CONTROL, CONST_LEN_STR("Cache-Control") }
,{ HTTP_HEADER_CONTENT_LENGTH, CONST_LEN_STR("Content-Length") }
,{ HTTP_HEADER_ACCEPT_ENCODING, CONST_LEN_STR("Accept-Encoding") }
,{ HTTP_HEADER_X_FORWARDED_FOR, CONST_LEN_STR("X-Forwarded-For") }
,{ HTTP_HEADER_CONTENT_ENCODING, CONST_LEN_STR("Content-Encoding") }
,{ HTTP_HEADER_CONTENT_LOCATION, CONST_LEN_STR("Content-Location") }
,{ HTTP_HEADER_IF_MODIFIED_SINCE, CONST_LEN_STR("If-Modified-Since") }
,{ HTTP_HEADER_TRANSFER_ENCODING, CONST_LEN_STR("Transfer-Encoding") }
,{ HTTP_HEADER_X_FORWARDED_PROTO, CONST_LEN_STR("X-Forwarded-Proto") }
,{ HTTP_HEADER_OTHER, 0, NULL }
};
enum http_header_e http_header_hkey_get(const char *s, size_t slen) {

Loading…
Cancel
Save