Page Speed Optimization Libraries
1.3.25.1
|
Read/write API for HTTP headers (shared base class) More...
#include "headers.h"
Public Member Functions | |
virtual void | Clear () |
int | major_version () const |
bool | has_major_version () const |
int | minor_version () const |
void | set_major_version (int major_version) |
void | set_minor_version (int major_version) |
int | NumAttributes () const |
Raw access for random access to attribute name/value pairs. | |
const GoogleString & | Name (int i) const |
const GoogleString & | Value (int i) const |
bool | Lookup (const StringPiece &name, ConstStringStarVector *values) const |
const char * | Lookup1 (const StringPiece &name) const |
bool | Has (const StringPiece &name) const |
Does there exist a header with given name. | |
bool | HasValue (const StringPiece &name, const StringPiece &value) const |
Is value one of the values in Lookup(name)? | |
int | NumAttributeNames () const |
NumAttributeNames is also const but not thread-safe. | |
void | RemoveCookie (const StringPiece &cookie_name) |
virtual void | Add (const StringPiece &name, const StringPiece &value) |
Adds a new header, even if a header with the 'name' exists already. | |
virtual bool | Remove (const StringPiece &name, const StringPiece &value) |
virtual bool | RemoveAll (const StringPiece &name) |
Removes all headers by name. Return true if anything was removed. | |
virtual bool | RemoveAllFromSet (const StringSetInsensitive &names) |
virtual void | RemoveAllWithPrefix (const StringPiece &prefix) |
Removes all headers whose name starts with prefix. | |
virtual void | Replace (const StringPiece &name, const StringPiece &value) |
virtual void | UpdateFrom (const Headers< Proto > &other) |
virtual bool | WriteAsBinary (Writer *writer, MessageHandler *message_handler) |
Serialize HTTP header to a binary stream. | |
virtual bool | ReadFromBinary (const StringPiece &buf, MessageHandler *handler) |
Read HTTP header from a binary string. | |
virtual bool | WriteAsHttp (Writer *writer, MessageHandler *handler) const |
Serialize HTTP headers in HTTP format so it can be re-parsed. | |
Static Public Member Functions | |
static void | RemoveFromHeaders (const StringSetInsensitive &names, protobuf::RepeatedPtrField< NameValue > *headers) |
Removes all headers whose name is in |names|. | |
Protected Member Functions | |
void | PopulateMap () const |
const is a lie, mutates map_. | |
Protected Attributes | |
scoped_ptr < StringMultiMapInsensitive > | map_ |
scoped_ptr< Proto > | proto_ |
Read/write API for HTTP headers (shared base class)
bool net_instaweb::Headers< Proto >::Lookup | ( | const StringPiece & | name, |
ConstStringStarVector * | values | ||
) | const |
Lookup attributes with provided name. Attribute values are stored in values. Returns true iff there were any attributes with provided name.
Note that Lookup, though declared const, is NOT thread-safe. This is because it lazily generates a map.
const char* net_instaweb::Headers< Proto >::Lookup1 | ( | const StringPiece & | name | ) | const |
Looks up a single attribute value. Returns NULL if the attribute is not found, or if more than one attribute is found.
virtual bool net_instaweb::Headers< Proto >::Remove | ( | const StringPiece & | name, |
const StringPiece & | value | ||
) | [virtual] |
Remove headers by name and value. Return true if anything was removed. Note: If the original headers were: attr: val1 attr: val2 attr: val3 and you Remove(attr, val2), your new headers will be: attr: val1, val3 (if attr is a comma-separated field) and - attr: val1 attr: val3 (otherwise).
Reimplemented in net_instaweb::ResponseHeaders.
virtual bool net_instaweb::Headers< Proto >::RemoveAllFromSet | ( | const StringSetInsensitive & | names | ) | [virtual] |
Removes all headers whose name is in |names|. Return true if anything was removed.
Reimplemented in net_instaweb::ResponseHeaders.
void net_instaweb::Headers< Proto >::RemoveCookie | ( | const StringPiece & | cookie_name | ) |
Remove all instances of cookie_name in all the cookie headers. Empty cookie headers will be removed. It might be better for performance if this function is called after checking that the cookie is present. CAVEAT: Double quoted values are not necessarily treated as one token. Please refer to the test cases in headers_cookie_util_test.cc for more details.
virtual void net_instaweb::Headers< Proto >::Replace | ( | const StringPiece & | name, |
const StringPiece & | value | ||
) | [virtual] |
Similar to RemoveAll followed by Add. Note that the attribute order may be changed as a side effect of this operation.
Reimplemented in net_instaweb::ResponseHeaders.
virtual void net_instaweb::Headers< Proto >::UpdateFrom | ( | const Headers< Proto > & | other | ) | [virtual] |
Merge headers. Replaces all headers specified both here and in other with the version in other. Useful for updating headers when recieving 304 Not Modified responses. Note: This is order-scrambling.
Reimplemented in net_instaweb::ResponseHeaders.
scoped_ptr<StringMultiMapInsensitive> net_instaweb::Headers< Proto >::map_ [mutable, protected] |
We have two represenations for the name/value pairs. The HttpResponseHeader protobuf contains a simple string-pair vector, but lacks a fast associative lookup. So we will build structures for associative lookup lazily, and keep them up-to-date if they are present.