Page Speed Optimization Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | List of all members
net_instaweb::RequestHeaders Class Reference

Read/write API for HTTP request (RequestHeaders is a misnomer). More...

#include "request_headers.h"

Inheritance diagram for net_instaweb::RequestHeaders:
net_instaweb::Headers< HttpRequestHeaders >


struct  Properties

Public Types

enum  Method {
  kOptions, kGet, kHead, kPost,
  kPut, kDelete, kTrace, kConnect,
  kPatch, kPurge, kError
- Public Types inherited from net_instaweb::Headers< HttpRequestHeaders >
typedef std::pair< StringPiece,
StringPiece > 
 typedef's for manipulating the cookie multimap.
typedef std::multimap
< StringPiece,
typedef std::multimap
< StringPiece,
ValueAndAttributes >

Public Member Functions

virtual void Clear ()
void CopyFromProto (const HttpRequestHeaders &p)
void CopyFrom (const RequestHeaders &other)
GoogleString ToString () const
Method method () const
const char * method_string () const
void set_method (Method method)
const GoogleStringmessage_body () const
void set_message_body (const GoogleString &data)
bool WriteAsHttp (const StringPiece &url, Writer *writer, MessageHandler *handler) const
bool AcceptsGzip () const
 Determines whether a request header accepts gzipped content.
bool IsXmlHttpRequest () const
void PopulateLazyCaches ()
Properties GetProperties () const
const CookieMultimap & GetAllCookies () const
bool HasCookie (StringPiece cookie_name) const
 Determines whether the specified Cookie is present in the request.
bool HasCookieValue (StringPiece cookie_name, StringPiece cookie_value) const
- Public Member Functions inherited from net_instaweb::Headers< HttpRequestHeaders >
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 GoogleStringName (int i) const
const GoogleStringValue (int i) const
void SetValue (int i, StringPiece value)
bool Lookup (const StringPiece &name, ConstStringStarVector *values) const
GoogleString LookupJoined (StringPiece name) 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)
void Add (const StringPiece &name, const StringPiece &value)
bool Remove (const StringPiece &name, const StringPiece &value)
bool RemoveAll (const StringPiece &name)
 Removes all headers by name. Return true if anything was removed.
bool RemoveAllFromSortedArray (const StringPiece *names, int names_size)
bool RemoveAllWithPrefix (const StringPiece &prefix)
bool RemoveIfNotIn (const Headers &keep)
virtual void Replace (const StringPiece &name, const StringPiece &value)
virtual void UpdateFrom (const Headers< HttpRequestHeaders > &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.
void CopyToProto (HttpRequestHeaders *proto) const
 Copy protobuf representation to "proto".

Additional Inherited Members

- Static Public Member Functions inherited from net_instaweb::Headers< HttpRequestHeaders >
static bool RemoveFromHeaders (const StringType *names, int names_size, protobuf::RepeatedPtrField< NameValue > *headers)
static bool FindValueForName (const StringPieceVector &name_equals_value_vec, StringPiece name_to_find, StringPiece *optional_retval)
static bool ExtractNameAndValue (StringPiece input, StringPiece *name, StringPiece *optional_retval)
- Protected Member Functions inherited from net_instaweb::Headers< HttpRequestHeaders >
void SetProto (HttpRequestHeaders *proto)
 You need to know what you're doing to use these, so for subclasses only. More...
void CopyProto (const HttpRequestHeaders &proto)
void PopulateMap () const
 const is a lie, mutates map_.
const CookieMultimap * PopulateCookieMap (StringPiece header_name) const
virtual void UpdateHook ()
const HttpRequestHeaders * proto () const
HttpRequestHeaders * mutable_proto ()

Detailed Description

Read/write API for HTTP request (RequestHeaders is a misnomer).

Member Function Documentation

const CookieMultimap& net_instaweb::RequestHeaders::GetAllCookies ( ) const

Return a const reference to the multimap of cookies. The mapping is: cookie name -> (cookie value, empty StringPiece) [the empty StringPiece is for cookie attributes; since Cookie headers don't have attributes it's empty; it's really for SetCookie headers] It's a multimap to cater for the same cookie being set multiple times; how this is handled is up to the caller.

bool net_instaweb::RequestHeaders::HasCookieValue ( StringPiece  cookie_name,
StringPiece  cookie_value 
) const

Determines whether the specified Cookie and value are present in the request.

bool net_instaweb::RequestHeaders::IsXmlHttpRequest ( ) const

Returns true if these request headers are for an XmlHttp request (i.e. ajax request). This mechanism is not reliable because sometimes this header is not set even for XmlHttp requests.

const GoogleString& net_instaweb::RequestHeaders::message_body ( ) const

This is encoded message body, a rewriter or fetcher may opt to translate to entity-body only after removing header which has encoding information.


TODO(atulvasu): Support something like a Rope for larger post bodies.

TODO(atulvasu): Use a Writer instead of a string.

void net_instaweb::RequestHeaders::PopulateLazyCaches ( )

Calling this method on an object that will not have any mutating operations called on it afterwards will ensure that it will not do any lazy initialization behind the scenes.

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