Public Member Functions | List of all members
BHttpHeaders Class Reference

Container for a set of HTTP headers. More...

Public Member Functions

 BHttpHeaders ()
 Construct an empty header list.
 
 BHttpHeaders (const BHttpHeaders &copy)
 Copy constructor. More...
 
bool AddHeader (const char *line)
 Add a new header to the list, from an HTTP header line. More...
 
bool AddHeader (const char *name, const char *value)
 Add a new header from the given key:value pair.
 
bool AddHeader (const char *name, int32 value)
 Convenience method to add a header with a numeric value.
 
void Clear ()
 Remove all HTTP headers from the list.
 
int32 CountHeaders () const
 
int32 HasHeader (const char *name) const
 Find an header by key. More...
 
BHttpHeaderHeaderAt (int32 index) const
 Find header by position. More...
 
const char * HeaderValue (const char *name) const
 

Detailed Description

Container for a set of HTTP headers.

This class allows management of the set of headers for a single HTTP transaction. They are stored in a list and can be iterated on.

Constructor & Destructor Documentation

◆ BHttpHeaders()

BHttpHeaders::BHttpHeaders ( const BHttpHeaders copy)

Copy constructor.

A deep copy is performed, so modifying the headers in the copy does not change the original.

Member Function Documentation

◆ AddHeader()

bool BHttpHeaders::AddHeader ( const char *  line)

Add a new header to the list, from an HTTP header line.

Duplicates headers are allowed.

Returns
false when out of memory.

◆ CountHeaders()

int32 BHttpHeaders::CountHeaders ( ) const
Returns
the number of entries in this set

◆ HasHeader()

int32 BHttpHeaders::HasHeader ( const char *  name) const

Find an header by key.

Returns
The index of the header for use with HeaderAt(), or B_ERROR if not found.

◆ HeaderAt()

BHttpHeader & BHttpHeaders::HeaderAt ( int32  index) const

Find header by position.

Parameters
indexmust be in bounds, else this method will crash.
See also
CountHeaders()

◆ HeaderValue()

const char * BHttpHeaders::HeaderValue ( const char *  name) const
Returns
the value mapped to the given key, or NULL if not found.