setup response header struct

This commit is contained in:
SuperNovaa41 2025-01-29 10:38:30 -05:00
parent 16481ec708
commit aaeac2ad7f
2 changed files with 92 additions and 0 deletions

3
src/headers.c Normal file
View File

@ -0,0 +1,3 @@
#include "include/headers.h"

89
src/include/headers.h Normal file
View File

@ -0,0 +1,89 @@
#include <stdlib.h>
#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