Encapsulates the headers portion of a request or response. More...
#include <Headers.h>
Inherits atscppapi::noncopyable.
Public Types | |
typedef unsigned int | size_type |
typedef header_field_iterator | iterator |
Public Member Functions | |
Headers () | |
Constructor for Headers. | |
Headers (void *bufp, void *mloc) | |
Constructor for Headers, this shouldn't be used directly unless you're trying to mix the C++ and C apis. | |
void | reset (void *bufp, void *mloc) |
Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue. | |
bool | isInitialized () const |
Check if the header class has been initialized. | |
bool | empty () |
Check if the headers are empty. | |
size_type | size () const |
Get the size of the headers (the number of HeaderFields). | |
size_type | lengthBytes () const |
Get the size of the headers (the number of HeaderFields). | |
iterator | begin () |
Returns an iterator to the start of the HeaderFields. | |
iterator | end () |
Returns an iterator to the end of the HeaderFields (beyond the last element). | |
bool | clear () |
Clears all headers. | |
bool | erase (iterator it) |
Erase a single header field pointed to by an iterator. | |
size_type | erase (const std::string &key) |
Erase all headers whose name matches key (this is a case insensitive match). | |
size_type | erase (const char *key, int length=-1) |
Erase all headers whose name matches key (this is a case insensitive match). | |
size_type | count (const char *key, int length=-1) |
Count all headers whose name matches key (this is a case insensitive match). | |
size_type | count (const std::string &key) |
Count all headers whose name matches key (this is a case insensitive match). | |
std::string | values (const std::string &key, const char *join=",") |
Join all headers whos name is key with the optionally specified join string. | |
std::string | values (const std::string &key, const std::string &join) |
Join all headers whos name is key with the optionally specified join string. | |
std::string | values (const std::string &key, const char join) |
Join all headers whos name is key with the optionally specified join character. | |
std::string | value (const std::string key, size_type index=0) |
Returns the value at given position of header with given name. | |
iterator | find (const std::string &key) |
Returns an iterator to the first HeaderField with the name key. | |
iterator | find (const char *key, int length=-1) |
Returns an iterator to the first HeaderField with the name key. | |
iterator | append (const std::string &key, const std::string &value) |
Append a HeaderField. | |
iterator | set (const std::string &key, const std::string &value) |
Erase all headers with name specified by key and then re-create the header with the specified values. | |
HeaderField | operator[] (const std::string &key) |
Set the header field values to the value given, the header field will be created if it does not already exist. | |
std::string | str () |
Get a human-readable/log-friendly string representing all the header fields. | |
std::string | wireStr () |
Get a string that can be put on the wire. | |
~Headers () | |
Friends | |
class | Request |
class | ClientRequest |
class | Response |
std::ostream & | operator<< (std::ostream &os, Headers &obj) |
Encapsulates the headers portion of a request or response.
Definition at line 396 of file Headers.h.
typedef unsigned int atscppapi::Headers::size_type |
atscppapi::Headers::Headers | ( | ) |
Constructor for Headers.
This creates a "detached" headers, i.e., not tied to any transaction.
atscppapi::Headers::Headers | ( | void * | bufp, | |
void * | mloc | |||
) |
Constructor for Headers, this shouldn't be used directly unless you're trying to mix the C++ and C apis.
bufp | the TSMBuffer associated with the headers | |
mloc | the TSMLoc associated with the headers. |
atscppapi::Headers::~Headers | ( | ) |
iterator atscppapi::Headers::append | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Append a HeaderField.
key | the name of the header field to append | |
value | the value of the header field to append |
iterator atscppapi::Headers::begin | ( | ) |
Returns an iterator to the start of the HeaderFields.
bool atscppapi::Headers::clear | ( | ) |
Clears all headers.
size_type atscppapi::Headers::count | ( | const char * | key, | |
int | length = -1 | |||
) |
Count all headers whose name matches key (this is a case insensitive match).
the | name of the header fields to erase | |
the | length of the key (optional). |
size_type atscppapi::Headers::count | ( | const std::string & | key | ) |
Count all headers whose name matches key (this is a case insensitive match).
the | name of the header fields to count |
bool atscppapi::Headers::empty | ( | ) |
Check if the headers are empty.
iterator atscppapi::Headers::end | ( | ) |
Returns an iterator to the end of the HeaderFields (beyond the last element).
bool atscppapi::Headers::erase | ( | iterator | it | ) |
Erase a single header field pointed to by an iterator.
an | iterator pointing to a header field. |
size_type atscppapi::Headers::erase | ( | const std::string & | key | ) |
Erase all headers whose name matches key (this is a case insensitive match).
the | name of the header fields to erase |
size_type atscppapi::Headers::erase | ( | const char * | key, | |
int | length = -1 | |||
) |
Erase all headers whose name matches key (this is a case insensitive match).
the | name of the header fields to erase | |
the | length of the key (optional). |
iterator atscppapi::Headers::find | ( | const std::string & | key | ) |
Returns an iterator to the first HeaderField with the name key.
key | the name of first header field ot find. |
iterator atscppapi::Headers::find | ( | const char * | key, | |
int | length = -1 | |||
) |
Returns an iterator to the first HeaderField with the name key.
key | the name of first header field ot find. | |
the | length of the key specified (optional). |
bool atscppapi::Headers::isInitialized | ( | ) | const |
Check if the header class has been initialized.
If you're only using the C++ api then this should always return true.
size_type atscppapi::Headers::lengthBytes | ( | ) | const |
Get the size of the headers (the number of HeaderFields).
HeaderField atscppapi::Headers::operator[] | ( | const std::string & | key | ) |
Set the header field values to the value given, the header field will be created if it does not already exist.
key | the name of the header field whose value to set. |
void atscppapi::Headers::reset | ( | void * | bufp, | |
void * | mloc | |||
) |
Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.
bufp | the TSMBuffer associated with the headers | |
mloc | the TSMLoc associated with the headers. |
iterator atscppapi::Headers::set | ( | const std::string & | key, | |
const std::string & | value | |||
) |
Erase all headers with name specified by key and then re-create the header with the specified values.
key | the name of the header field to erased and re-created. | |
value | the value of the header field to set. |
size_type atscppapi::Headers::size | ( | ) | const |
Get the size of the headers (the number of HeaderFields).
std::string atscppapi::Headers::str | ( | ) |
Get a human-readable/log-friendly string representing all the header fields.
std::string atscppapi::Headers::value | ( | const std::string | key, | |
size_type | index = 0 | |||
) |
Returns the value at given position of header with given name.
name | of header | |
position | of value |
std::string atscppapi::Headers::values | ( | const std::string & | key, | |
const char * | join = "," | |||
) |
Join all headers whos name is key with the optionally specified join string.
the | name of the headers to join into a single string | |
an | optional join string (defaults to ",") |
std::string atscppapi::Headers::values | ( | const std::string & | key, | |
const std::string & | join | |||
) |
Join all headers whos name is key with the optionally specified join string.
the | name of the headers to join into a single string | |
the | string to join the fields with |
std::string atscppapi::Headers::values | ( | const std::string & | key, | |
const char | join | |||
) |
Join all headers whos name is key with the optionally specified join character.
the | name of the headers to join into a single string | |
the | join character. |
std::string atscppapi::Headers::wireStr | ( | ) |
Get a string that can be put on the wire.
friend class ClientRequest [friend] |
std::ostream& operator<< | ( | std::ostream & | os, | |
Headers & | obj | |||
) | [friend] |