From aaeac2ad7ff49d438a9b45c2bfbc1cc1f3ac90fc Mon Sep 17 00:00:00 2001 From: SuperNovaa41 Date: Wed, 29 Jan 2025 10:38:30 -0500 Subject: [PATCH] setup response header struct --- src/headers.c | 3 ++ src/include/headers.h | 89 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/headers.c create mode 100644 src/include/headers.h diff --git a/src/headers.c b/src/headers.c new file mode 100644 index 0000000..3148e7c --- /dev/null +++ b/src/headers.c @@ -0,0 +1,3 @@ +#include "include/headers.h" + + diff --git a/src/include/headers.h b/src/include/headers.h new file mode 100644 index 0000000..b9bc7ef --- /dev/null +++ b/src/include/headers.h @@ -0,0 +1,89 @@ +#include + +#ifndef HEADERS_H +#define HEADERS_H + +/** + * Response Headers + */ +typedef enum { + BYTES, // bytes + NONE // none +} accept_ranges_t; + +struct response_headers { + /** + * Accept-Ranges: ... + * + * If we should accept a range request for a resource, defaults to NONE + * + * + */ + accept_ranges_t accept_ranges; + + /** + * Age: ... + * + * represents time in seconds + * + * time since the response was generated, this is for cached responses, + * if we are cacheing, this header is REQUIRED + */ + uint age; + + /** + * ETag: ... + * + * Current value of the entity tag for the requested tag + * only useful if we're sending an entity body+header aswell + */ + const char* etag; + + /** + * Location: absoluteURI + * + * For 201 (created), this should be the new source that was created + * for 3xx this should indicate the servers preferred URI for automatic redirection + */ + const char* location; + + /** + * Proxy-Authenticate: ... + * + * For 407 this is a required field + */ + const char* proxy_authenticate; + + /** + * Retry-After: (HTTP-date | delta-seconds) + * + * can be used with a 503 to indicate how long its expeccted to be unavailable + * may be used with 3xx to tell how long to wait before redirecting + */ + const char* retry_after; + + /** + * Server: product/version ... + * + * Information about the HTTP server + */ + const char* server; + + /** + * Vary: (* | field-name) + * + * This is for a cacheable (or non cacheable reponse) + * that is subject to server-driven negotiation + */ + const char* vary; + + /** + * WWW-Authenticate: ... + * + * required for 401 + */ + const char* www_authenticate; + +}; + +#endif