Encapsulates a set of HTTP header information. More...

#include <HttpHeaders.h>

Inheritance diagram for HttpHeaders:
[legend]
Collaboration diagram for HttpHeaders:
[legend]

Public Member Functions

 HttpHeaders ()=default
 
 HttpHeaders (const HttpHeaders &headers)
 
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...
 
const Stringoperator[] (const String &name) const
 Fetch a reference to the header field value by name. More...
 
Stringoperator[] (const String &name)
 Fetch a reference to the header field value by name. More...
 
String operator[] (unsigned index) const
 Return the HTTP header line for the value at the given index. More...
 
bool contains (const String &name) const
 
void remove (const String &name)
 
void setMultiple (const HttpHeaders &headers)
 
HttpHeadersoperator= (const HttpHeaders &headers)
 
void clear ()
 
DateTime getLastModifiedDate () const
 
DateTime getServerDate () const
 

Static Public Member Functions

static String toString (const String &name, const String &value)
 Produce a string for output in the HTTP header, with line ending. More...
 

Private Types

typedef bool(* comparator) (const HttpHeaderFieldName &, const HttpHeaderFieldName &)
 

Private Member Functions

unsigned int count () const
 
const HttpHeaderFieldNamekeyAt (unsigned int idx) const
 
HttpHeaderFieldNamekeyAt (unsigned int idx)
 
const StringvalueAt (unsigned int idx) const
 
StringvalueAt (unsigned int idx)
 
const Stringoperator[] (const HttpHeaderFieldName &key) const
 
Stringoperator[] (const HttpHeaderFieldName &key)
 
void allocate (unsigned int newSize)
 
int indexOf (const HttpHeaderFieldName &key) const
 
bool contains (const HttpHeaderFieldName &key) const
 
void removeAt (unsigned index)
 
void remove (const HttpHeaderFieldName &key)
 
void setMultiple (const HashMap< HttpHeaderFieldName, String > &map)
 
void setNullValue (const String &nullv)
 

Private Attributes

HttpHeaderFieldName ** keys
 
String ** values
 
String nil
 
uint16_t currentIndex
 
uint16_t size
 
comparator cb_comparator
 

Detailed Description

Encapsulates a set of HTTP header information.

Note
fields are stored as a map of field names vs. values. Standard fields may be accessed using enumeration tags. Behaviour is as for HashMap, with the addition of methods to support enumerated field names.
Todo:
add name and/or value escaping

Constructor & Destructor Documentation

◆ HttpHeaders() [1/2]

HttpHeaders::HttpHeaders ( )
default

◆ HttpHeaders() [2/2]

HttpHeaders::HttpHeaders ( const HttpHeaders headers)
inline

Member Function Documentation

◆ clear()

void HttpHeaders::clear ( )
inline

◆ contains()

bool HttpHeaders::contains ( const String name) const
inline

◆ fromString()

HttpHeaderFieldName HttpHeaders::fromString ( const String name) const

Find the enumerated value for the given field name string.

Parameters
name
Return values
HttpHeaderFieldNamefield name code, HTTP_HEADER_UNKNOWN if not recognised
Note
comparison is not case-sensitive

◆ getLastModifiedDate()

DateTime HttpHeaders::getLastModifiedDate ( ) const
inline

◆ getServerDate()

DateTime HttpHeaders::getServerDate ( ) const
inline

◆ operator=()

HttpHeaders& HttpHeaders::operator= ( const HttpHeaders headers)
inline

◆ operator[]() [1/3]

const String& HttpHeaders::operator[] ( const String name) const
inline

Fetch a reference to the header field value by name.

Parameters
name
Return values
constString& Reference to value
Note
if the field doesn't exist a null String reference is returned

◆ operator[]() [2/3]

String& HttpHeaders::operator[] ( const String name)
inline

Fetch a reference to the header field value by name.

Parameters
name
Return values
String&Reference to value
Note
if the field doesn't exist it is created with the default null value

◆ operator[]() [3/3]

String HttpHeaders::operator[] ( unsigned  index) const
inline

Return the HTTP header line for the value at the given index.

Parameters
index
Return values
String
Note
if the index is invalid,

◆ remove()

void HttpHeaders::remove ( const String name)
inline

◆ setMultiple()

void HttpHeaders::setMultiple ( const HttpHeaders headers)
inline

◆ toString() [1/3]

String HttpHeaders::toString ( HttpHeaderFieldName  name) const

◆ toString() [2/3]

static String HttpHeaders::toString ( const String name,
const String value 
)
static

Produce a string for output in the HTTP header, with line ending.

Parameters
name
value
Return values
String

◆ toString() [3/3]

String HttpHeaders::toString ( HttpHeaderFieldName  name,
const String value 
) const
inline

The documentation for this class was generated from the following file: