adds all the headers in the structs

This commit is contained in:
SuperNovaa41 2025-01-30 12:44:22 -05:00
parent aaeac2ad7f
commit e04f9b6d95

View File

@ -3,13 +3,94 @@
#ifndef HEADERS_H #ifndef HEADERS_H
#define HEADERS_H #define HEADERS_H
/** struct general_headers {
* Response Headers /**
* Cache-Control: ...
*
* Used to control the cache
*
* TODO: implement cache,
* for no we will be using "no-cache" for response
*/ */
typedef enum { const char* cache_control;
BYTES, // bytes
NONE // none /**
} accept_ranges_t; * Connection: ...
*
* requests will often have "keep-alive", but since we don't
* support maintain constant connections, every header must have
* "close"
*
* TODO: implmenet constant connections?
*/
const char* connection;
/**
* Date: HTTP-date
*
* must always be included unless the status code is 100 or 101
* or 500/503 if its inconvenient/impossible to generate a valid Date
*/
const char* date;
/**
* Pragma: ...
*
* no-cache control directive should be paired with Pragma: "no-cache"
*/
const char* pragma;
/**
* Trailer: fieldnames...
*
* This indicates that there will be a trailing header with the provided
* field names
*
* If there is no trailer, this field should not include anything
*
* can not include the following header fields:
* transfer-encoding
* content-length
* trailer
*/
const char* trailer;
/**
* Transfer-Encoding: ...
*
* Indicates what type of transformation has been applied to
* the message body
*/
const char* transfer_encoding;
/**
* Upgrade: ...
*
* Allows the client to specify what additional protocols
* it supports and would like to use
*
* Must use this in the 101 (Switching Protocols) response
*/
const char* upgrade;
/**
* Via: ...
*
* MUST be used by gateways and proxies to indicate
* intermediate protocols and receipients
*/
const char* via;
/**
* Warning: ...
*
* carries additional info about the status or transformation
* of a message, which might not be reflected in the message
*
* may carry more than one header TODO: implement this i suppose
*/
const char* warning;
};
struct response_headers { struct response_headers {
/** /**
@ -19,7 +100,7 @@ struct response_headers {
* *
* *
*/ */
accept_ranges_t accept_ranges; const char* accept_ranges;
/** /**
* Age: ... * Age: ...
@ -83,7 +164,29 @@ struct response_headers {
* required for 401 * required for 401
*/ */
const char* www_authenticate; const char* www_authenticate;
}; };
struct request_headers {
const char* accept;
const char* accept_charset;
const char* accept_encoding;
const char* accept_language;
const char* authorization;
const char* expect;
const char* from;
const char* host;
const char* if_match;
const char* if_modified_since;
const char* if_none_match;
const char* if_range;
const char* if_unmodified_since;
const char* max_forwards;
const char* proxy_authorization;
const char* range;
const char* referer;
const char* te;
const char* user_agent;
};
#endif #endif