![]() |
Thoth
A functional, expressive, asynchronous C++26 webdev library
|
Represents the collection of HTTP headers associated with a request. Based on modern HTTP RFCs and inspired by .NET's HttpRequestHeaders. More...
#include <RequestHeaders.hpp>
Public Member Functions | |
| NHeaders::ListProxy< false, string > | AcceptLanguage () |
| The value of the Accept-Language header. | |
| NHeaders::ListProxy< true, string > | AcceptLanguage () const |
| NHeaders::ListProxy< false, NHeaders::TeEnum > | Te () |
| The value of the TE (Transfer Encoding) header. | |
| NHeaders::ListProxy< true, NHeaders::TeEnum > | Te () const |
Raw and Collection Views | |
Methods for accessing headers without immediate parsing or as raw collections. | |
| auto | GetNonValidatedView () const |
| Gets a view of the contents of this headers collection that does not parse nor validate data. | |
| auto | GetCookiesView () const |
| Gets a readonly view of all Cookie values. | |
Public Member Functions inherited from Thoth::Http::Headers | |
| Headers () | |
| Headers (const MapType &initAs) | |
| Create with an existing vector. | |
| Headers (std::initializer_list< HeaderPair > init) | |
| bool | Exists (HeaderKeyRef key) const |
| check if a key exists. | |
| bool | Exists (HeaderPairRef p) const |
| check if a key exists. | |
| bool | Exists (HeaderKeyRef key, HeaderValueRef val) const |
| check if a key=val exists. | |
| void | Add (HeaderPairRef p) |
| Add a value with the specified key. Append if already exists. | |
| void | Add (HeaderKeyRef key, HeaderValueRef val) |
| same as Add(HeaderPairRef p). | |
| void | Set (HeaderPairRef p) |
| Add a value with the specified key. Replace if already exists. | |
| void | Set (HeaderKeyRef key, HeaderValueRef val) |
| same as Add(HeaderPairRef p). | |
| bool | Remove (HeaderPairRef p) |
| Remove a value with the specified key. | |
| bool | Remove (HeaderKeyRef key, HeaderValueRef val) |
| same as Remove(HeaderPairRef p). | |
| bool | SetIfNull (HeaderPairRef p) |
| If key not exists, set it to value. | |
| bool | SetIfNull (HeaderKeyRef key, HeaderValueRef val) |
| same as SetIfNull(HeaderPairRef p). | |
| std::optional< HeaderValue * > | Get (HeaderKeyRef key) |
| Get the reference of a key but don't create if it not exists. | |
| std::optional< const HeaderValue * > | Get (HeaderKeyRef key) const |
| Get the reference of a key but don't create if it not exists. | |
| IterType | begin () |
| IterType | end () |
| CIterType | begin () const |
| CIterType | end () const |
| RIterType | rbegin () |
| RIterType | rend () |
| CRIterType | rbegin () const |
| CRIterType | rend () const |
| void | Clear () |
| Clear all keys. | |
| size_t | Size () const |
| bool | Empty () const |
| HeaderValue & | operator[] (HeaderKeyRef key) |
| bool | operator== (const Headers &other) const |
| NHeaders::ListProxy< false, NHeaders::MimeType > | Accept () |
| Accept-Encoding header (gzip, br, etc). | |
| NHeaders::ListProxy< true, NHeaders::MimeType > | Accept () const |
| NHeaders::ListProxy< false, NHeaders::AcceptEncodingEnum > | AcceptEncoding () |
| Accept-Encoding header (gzip, br, etc). | |
| NHeaders::ListProxy< true, NHeaders::AcceptEncodingEnum > | AcceptEncoding () const |
| NHeaders::ValueProxy< false, NHeaders::MimeType > | ContentType () |
| Defines the media type of the resource (MIME). | |
| NHeaders::ValueProxy< true, NHeaders::MimeType > | ContentType () const |
| Defines the media type of the resource (MIME). | |
| NHeaders::ValueProxy< false, uint64_t > | ContentLength () |
| The size of the entity-body in bytes. | |
| NHeaders::ValueProxy< true, uint64_t > | ContentLength () const |
| The size of the entity-body in bytes. | |
| NHeaders::ListProxy< false, NHeaders::ContentEncodingEnum > | ContentEncoding () |
| List of encodings (compression) applied to the entity. | |
| NHeaders::ListProxy< true, NHeaders::ContentEncodingEnum > | ContentEncoding () const |
| List of encodings (compression) applied to the entity. | |
| NHeaders::ListProxy< false, NHeaders::TransferEncodingEnum > | TransferEncoding () |
| List of compression applied to the entity. | |
| NHeaders::ListProxy< true, NHeaders::TransferEncodingEnum > | TransferEncoding () const |
| List of compression applied to the entity. | |
| NHeaders::ListProxy< false, std::string > | ContentLanguage () |
| Natural languages for the intended audience (e.g., "en-US"). | |
| NHeaders::ListProxy< true, std::string > | ContentLanguage () const |
| Natural languages for the intended audience (e.g., "en-US"). | |
| NHeaders::ValueProxy< false, std::string > | ContentLocation () |
| The specific location for the entity-body. | |
| NHeaders::ValueProxy< true, std::string > | ContentLocation () const |
| The specific location for the entity-body. | |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point > | Date () |
| Date and time at which the message was originated. | |
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point > | Date () const |
| Date and time at which the message was originated. | |
| NHeaders::ListProxy< false, std::string > | Connection () |
| Options for the current connection. | |
| NHeaders::ListProxy< true, std::string > | Connection () const |
| Options for the current connection. | |
| NHeaders::ListProxy< false, NHeaders::Upgrade > | Upgrade () |
| Used to signal a protocol change (e.g., "websocket"). | |
| NHeaders::ListProxy< true, NHeaders::Upgrade > | Upgrade () const |
| Used to signal a protocol change (e.g., "websocket"). | |
| NHeaders::ListProxy< false, std::string > | Trailer () |
| Indicates header fields present in the trailer of a chunked message. | |
| NHeaders::ListProxy< true, std::string > | Trailer () const |
| Indicates header fields present in the trailer of a chunked message. | |
| NHeaders::ListProxy< false, std::string > | Via () |
| Path taken by the request/response through proxies (free std::string). | |
| NHeaders::ListProxy< true, std::string > | Via () const |
| Path taken by the request/response through proxies (free std::string). | |
Request Specific Proxies | |
Convenient calls to some headers. | |
| using | Url = string |
| NHeaders::ValueProxy< false, std::string > | Authorization () |
| NHeaders::ValueProxy< true, std::string > | Authorization () const |
| NHeaders::ValueProxy< false, Url > | Host () |
| Gets the Host header. Essential for HTTP/1.1 and SNI. | |
| NHeaders::ValueProxy< true, Url > | Host () const |
| NHeaders::ValueProxy< false, Url > | Referrer () |
| The value of the Referer header (yes, it's misspelled in RFC). | |
| NHeaders::ValueProxy< true, Url > | Referrer () const |
| NHeaders::ValueProxy< false, Url, std::monostate > | Origin () |
| The value of the Origin header. Used for CORS requests. | |
| NHeaders::ValueProxy< true, Url, std::monostate > | Origin () const |
| NHeaders::ValueProxy< false, string > | From () |
| The value of the From header (email address of the user). | |
| NHeaders::ValueProxy< true, string > | From () const |
| NHeaders::ValueProxy< false, unsigned int > | MaxForwards () |
| The value of the Max-Forwards header for limiting proxy hops. | |
| NHeaders::ValueProxy< true, unsigned int > | MaxForwards () const |
| NHeaders::ValueProxy< false, string > | ProxyAuthorization () |
| The value of the Proxy-Authorization header. | |
| NHeaders::ValueProxy< true, string > | ProxyAuthorization () const |
| NHeaders::ListProxy< false, NHeaders::Range > | Range () |
| The value of the Range header for partial content requests. | |
| NHeaders::ListProxy< true, NHeaders::Range > | Range () const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point > | IfModifiedSince () |
| The value of the If-Modified-Since header. | |
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point > | IfModifiedSince () const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point > | IfUnmodifiedSince () |
| The value of the If-Unmodified-Since header. | |
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point > | IfUnmodifiedSince () const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point, string > | IfRange () |
| The value of the If-Range header. | |
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point, string > | IfRange () const |
| NHeaders::ListProxy< false, NHeaders::EntityTag > | IfMatch () |
| The value of the If-Match header. | |
| NHeaders::ListProxy< true, NHeaders::EntityTag > | IfMatch () const |
| NHeaders::ValueProxy< false, NHeaders::EntityTag > | IfNoneMatch () |
| The value of the If-None-Match header. | |
| NHeaders::ValueProxy< true, NHeaders::EntityTag > | IfNoneMatch () const |
Additional Inherited Members | |
Public Types inherited from Thoth::Http::Headers | |
| using | HeaderKey = NHeaders::HeaderKey |
| using | HeaderKeyRef = NHeaders::HeaderKeyRef |
| using | HeaderValue = NHeaders::HeaderValue |
| using | HeaderValueRef = NHeaders::HeaderValueRef |
| using | HeaderPair = NHeaders::HeaderPair |
| using | HeaderPairRef = NHeaders::HeaderPairRef |
| using | MapType = NHeaders::MapType |
| using | MapType = std::vector< HeaderPair > |
| using | IterType = decltype(MapType{}.begin()) |
| using | CIterType = decltype(MapType{}.cbegin()) |
| using | RIterType = decltype(MapType{}.rbegin()) |
| using | CRIterType = decltype(MapType{}.crbegin()) |
Static Public Member Functions inherited from Thoth::Http::Headers | |
| template<std::ranges::input_range R> | |
| static WebResult< Headers > | Parse (R &headers, size_t maxHeadersLength=1<< 16) |
| Tries to parse the headers from the raw TCP std::string. | |
| static Headers | DefaultHeaders () |
Represents the collection of HTTP headers associated with a request. Based on modern HTTP RFCs and inspired by .NET's HttpRequestHeaders.
| NHeaders::ListProxy< false, string > Thoth::Http::RequestHeaders::AcceptLanguage | ( | ) |
The value of the Accept-Language header.
| NHeaders::ListProxy< true, string > Thoth::Http::RequestHeaders::AcceptLanguage | ( | ) | const |
| NHeaders::ValueProxy< false, std::string > Thoth::Http::RequestHeaders::Authorization | ( | ) |
| NHeaders::ValueProxy< true, std::string > Thoth::Http::RequestHeaders::Authorization | ( | ) | const |
| NHeaders::ValueProxy< false, string > Thoth::Http::RequestHeaders::From | ( | ) |
The value of the From header (email address of the user).
| NHeaders::ValueProxy< true, string > Thoth::Http::RequestHeaders::From | ( | ) | const |
| auto Thoth::Http::RequestHeaders::GetCookiesView | ( | ) | const |
Gets a readonly view of all Cookie values.
| auto Thoth::Http::RequestHeaders::GetNonValidatedView | ( | ) | const |
Gets a view of the contents of this headers collection that does not parse nor validate data.
| NHeaders::ValueProxy< false, Url > Thoth::Http::RequestHeaders::Host | ( | ) |
Gets the Host header. Essential for HTTP/1.1 and SNI.
| NHeaders::ValueProxy< true, Url > Thoth::Http::RequestHeaders::Host | ( | ) | const |
| NHeaders::ListProxy< false, NHeaders::EntityTag > Thoth::Http::RequestHeaders::IfMatch | ( | ) |
The value of the If-Match header.
| NHeaders::ListProxy< true, NHeaders::EntityTag > Thoth::Http::RequestHeaders::IfMatch | ( | ) | const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point > Thoth::Http::RequestHeaders::IfModifiedSince | ( | ) |
The value of the If-Modified-Since header.
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point > Thoth::Http::RequestHeaders::IfModifiedSince | ( | ) | const |
| NHeaders::ValueProxy< false, NHeaders::EntityTag > Thoth::Http::RequestHeaders::IfNoneMatch | ( | ) |
The value of the If-None-Match header.
| NHeaders::ValueProxy< true, NHeaders::EntityTag > Thoth::Http::RequestHeaders::IfNoneMatch | ( | ) | const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point, string > Thoth::Http::RequestHeaders::IfRange | ( | ) |
The value of the If-Range header.
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point, string > Thoth::Http::RequestHeaders::IfRange | ( | ) | const |
| NHeaders::ValueProxy< false, std::chrono::utc_clock::time_point > Thoth::Http::RequestHeaders::IfUnmodifiedSince | ( | ) |
The value of the If-Unmodified-Since header.
| NHeaders::ValueProxy< true, std::chrono::utc_clock::time_point > Thoth::Http::RequestHeaders::IfUnmodifiedSince | ( | ) | const |
| NHeaders::ValueProxy< false, unsigned int > Thoth::Http::RequestHeaders::MaxForwards | ( | ) |
The value of the Max-Forwards header for limiting proxy hops.
| NHeaders::ValueProxy< true, unsigned int > Thoth::Http::RequestHeaders::MaxForwards | ( | ) | const |
| NHeaders::ValueProxy< false, Url, std::monostate > Thoth::Http::RequestHeaders::Origin | ( | ) |
The value of the Origin header. Used for CORS requests.
| NHeaders::ValueProxy< true, Url, std::monostate > Thoth::Http::RequestHeaders::Origin | ( | ) | const |
| NHeaders::ValueProxy< false, string > Thoth::Http::RequestHeaders::ProxyAuthorization | ( | ) |
The value of the Proxy-Authorization header.
| NHeaders::ValueProxy< true, string > Thoth::Http::RequestHeaders::ProxyAuthorization | ( | ) | const |
| NHeaders::ListProxy< false, NHeaders::Range > Thoth::Http::RequestHeaders::Range | ( | ) |
The value of the Range header for partial content requests.
| NHeaders::ListProxy< true, NHeaders::Range > Thoth::Http::RequestHeaders::Range | ( | ) | const |
| NHeaders::ValueProxy< false, Url > Thoth::Http::RequestHeaders::Referrer | ( | ) |
The value of the Referer header (yes, it's misspelled in RFC).
| NHeaders::ValueProxy< true, Url > Thoth::Http::RequestHeaders::Referrer | ( | ) | const |
| NHeaders::ListProxy< false, NHeaders::TeEnum > Thoth::Http::RequestHeaders::Te | ( | ) |
The value of the TE (Transfer Encoding) header.
| NHeaders::ListProxy< true, NHeaders::TeEnum > Thoth::Http::RequestHeaders::Te | ( | ) | const |