BasicHttpHeaders Class Reference
Parse array of name/value pairs as references to original data. More...
#include <BasicHttpHeaders.h>
Inheritance diagram for BasicHttpHeaders:
Collaboration diagram for BasicHttpHeaders:
Classes | |
| struct | Header |
Public Member Functions | |
| BasicHttpHeaders () | |
| void | clear () |
| Reset to default state. More... | |
| HttpError | parse (char *data, size_t len, http_parser_type type=HTTP_BOTH) |
| Parse header data into name/value pairs. More... | |
| const Header & | operator[] (unsigned i) const |
| String | toString (unsigned i) const |
| const char *& | operator[] (const char *name) |
| unsigned | count () const |
| Get number of parsed headers. More... | |
| const char * | operator[] (const char *name) const |
| Find a header by name. More... | |
| const char * | operator[] (HttpHeaderFieldName name) const |
| bool | contains (const char *name) const |
| bool | contains (HttpHeaderFieldName name) const |
| http_parser_type | type () const |
| Get the type of message parsed. More... | |
| HttpMethod | method () const |
| Obtain request method. More... | |
| void | setMethod (HttpMethod method) |
| HttpStatus | status () const |
| Obtain response status. More... | |
| unsigned | contentLength () const |
| Obtain content length field value. More... | |
Public Member Functions inherited from HttpHeaderFields | |
| Flags | getFlags (HttpHeaderFieldName name) const |
| Get flags (if any) for given header field. More... | |
| String | toString (HttpHeaderFieldName name) const |
| String | toString (HttpHeaderFieldName name, const String &value) const |
| HttpHeaderFieldName | fromString (const String &name) const |
| Find the enumerated value for the given field name string. More... | |
| HttpHeaderFieldName | findOrCreate (const String &name) |
| Find the enumerated value for the given field name string, create a custom entry if not found. More... | |
| void | clear () |
Static Public Attributes | |
| static constexpr size_t | maxValues = 16 |
Additional Inherited Members | |
Public Types inherited from HttpHeaderFields | |
| enum | Flag { Flag::Multi } |
| Flag values providing additional information about header fields. More... | |
| using | Flags = BitSet< uint8_t, Flag, 1 > |
Static Public Member Functions inherited from HttpHeaderFields | |
| static String | toString (const String &name, const String &value) |
| Produce a string for output in the HTTP header, with line ending. More... | |
Detailed Description
Parse array of name/value pairs as references to original data.
- Note
- When parsing a fixed block of text we don't need to make copies of the content, just nul-terminate the elements and build a list of references.
Constructor & Destructor Documentation
◆ BasicHttpHeaders()
|
inline |
Member Function Documentation
◆ clear()
| void BasicHttpHeaders::clear | ( | ) |
Reset to default state.
◆ contains() [1/2]
|
inline |
◆ contains() [2/2]
|
inline |
◆ contentLength()
|
inline |
Obtain content length field value.
◆ count()
|
inline |
Get number of parsed headers.
◆ method()
|
inline |
Obtain request method.
◆ operator[]() [1/4]
| const char*& BasicHttpHeaders::operator[] | ( | const char * | name | ) |
◆ operator[]() [2/4]
| const char* BasicHttpHeaders::operator[] | ( | const char * | name | ) | const |
Find a header by name.
- Parameters
-
name Case-insensitive
- Return values
-
const char* If found, the value, otherwise nullptr
◆ operator[]() [3/4]
|
inline |
◆ operator[]() [4/4]
◆ parse()
Parse header data into name/value pairs.
- Parameters
-
data len type Type of headers to parse. The default (HTTP_BOTH) detects this automatically, use type()to determine which. Specifying HTTP_REQUEST or HTTP_RESPONSE will only accept the given type and fail on mismatch.
- Return values
-
HttpError Result of parsing, HPE_OK on success. Can use with toString()orhttpGetErrorDescription().
- Note
- Content of provided data is modified to insert NUL terminators on string values Use type() method to determine whether it's a request or response
◆ setMethod()
|
inline |
◆ status()
|
inline |
Obtain response status.
◆ toString()
◆ type()
|
inline |
Get the type of message parsed.
- Return values
-
http_parser_type either HTTP_REQUEST or HTTP_RESPONSE
Member Data Documentation
◆ maxValues
|
staticconstexpr |
The documentation for this class was generated from the following file:
Public Member Functions inherited from
1.8.17