Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::Network::HTTPMessage Class Referenceabstract

A base class for HTTP text parsing classes. More...

#include <httpmessage.h>

+ Inheritance diagram for Mezzanine::Network::HTTPMessage:
+ Collaboration diagram for Mezzanine::Network::HTTPMessage:

Public Types

typedef HeaderFieldContainer::const_iterator ConstHeaderFieldIterator
 Const Iterator type for Header Fields in this class.
 
typedef std::vector< HeaderFieldHeaderFieldContainer
 Container type for Header Fields in this class.
 
typedef HeaderFieldContainer::iterator HeaderFieldIterator
 Iterator type for Header Fields in this class.
 
typedef String::const_iterator StringIterator
 Convenience typedef for String iterators.
 

Public Member Functions

virtual String Compose () const =0
 Creates a completed Message that can be sent across an HTTP connection. More...
 
virtual Boole Decompose (const String &Message)=0
 Populates the members of this class with data from a text HTTP Message. More...
 
virtual Boole Decompose (StringIterator &CurrIt, const StringIterator EndIt)=0
 Populates the members of this class with data from a text HTTP Message. More...
 
const StringGetBody () const
 Gets the message body containing additional information. More...
 
const StringGetConnectionHeader () const
 Gets the Connection Header. More...
 
const StringGetContentLengthHeader () const
 Gets the Content-Length Header. More...
 
const StringGetContentTypeHeader () const
 Gets the Content-Type Header. More...
 
const StringGetField (const String &FieldName) const
 Gets a Name-Value pair for a header field in the message. More...
 
UInt16 GetHTTPMajorVersion () const
 Gets the major version of this message. More...
 
UInt16 GetHTTPMinorVersion () const
 Gets the minor version of this message. More...
 
const SimpleVersionGetHTTPVersion () const
 Gets both the major and minor version of this message. More...
 
Whole GetMaxFields () const
 Gets how many header fields can be added to this message during parsing. More...
 
Boole HasField (const String &FieldName) const
 Checks if this message has the named header field. More...
 
void RemoveAllFields ()
 Removes every field from this message.
 
void RemoveField (const String &FieldName)
 Removes a specific field from this message by name. More...
 
void SetBody (const String &Body)
 Sets the message body containing additional information. More...
 
void SetConnectionHeader (const String &Connection)
 Sets the Connection Header. More...
 
void SetContentLengthHeader (const String &ContentLength)
 Sets the Content-Length Header. More...
 
void SetContentTypeHeader (const String &ContentType)
 Sets the Content-Type Header. More...
 
void SetField (const String &FieldName, const String &FieldValue)
 Sets a Name-Value pair for a header field in the message. More...
 
void SetHTTPMajorVersion (const UInt16 Major)
 Sets the major version of this message. More...
 
void SetHTTPMinorVersion (const UInt16 Minor)
 Sets the minor version of this message. More...
 
void SetHTTPVersion (const SimpleVersion &Version)
 Sets both the major and minor version of this message via SimpleVersion. More...
 
void SetHTTPVersion (const UInt16 Major, const UInt16 Minor)
 Sets both the major and minor version of this message. More...
 
void SetMaxFields (const Whole MaxFields)
 Sets how many header fields can be added to this message during parsing. More...
 

Protected Member Functions

 HTTPMessage ()
 Blank Constructor.
 
 HTTPMessage (const UInt16 VerMajor, const UInt16 VerMinor)
 UInt Version Constructor.
 
 HTTPMessage (const SimpleVersion &Version)
 Version Constructor.
 
virtual ~HTTPMessage ()
 Class destructor.
 
void AdvanceToNewline (StringIterator &CurrIt, const StringIterator EndIt)
 Convenience method that will ignore and advance passed all characters until one passed the first newline character detected. More...
 
Boole GetMessageComponent (StringIterator &CurrIt, const StringIterator EndIt, String &Component)
 Extracts all characters from CurrIt until the first space encountered or EndIt, whichever comes first. More...
 
Boole ParseHTTPFields (StringIterator &CurrIt, const StringIterator EndIt)
 Parses the HTTP fields from a provided string. More...
 
virtual Boole ParseHTTPHeader (StringIterator &CurrIt, const StringIterator EndIt)=0
 Parses the information contained in the Message Header. More...
 
Boole ParseHTTPVersion (const String &ToParse)
 Parses the HTTP version from a provided string. More...
 

Protected Attributes

Whole MaxHeaderFields
 The maximum number of allowed header fields in this message. More...
 
String MessageBody
 The body of the message. More...
 
HeaderFieldContainer MessageFields
 A container of fields to populate the message header with. More...
 
SimpleVersion MessageVersion
 The version component for this response. More...
 

Detailed Description

A base class for HTTP text parsing classes.

Definition at line 73 of file httpmessage.h.

Member Function Documentation

void Mezzanine::Network::HTTPMessage::AdvanceToNewline ( StringIterator CurrIt,
const StringIterator  EndIt 
)
protected

Convenience method that will ignore and advance passed all characters until one passed the first newline character detected.

Parameters
CurrItAn iterator to the current character being processed in the string being parsed.
EndItAn iterator to the last character in the string to be parsed.

Definition at line 197 of file httpmessage.cpp.

virtual String Mezzanine::Network::HTTPMessage::Compose ( ) const
pure virtual

Creates a completed Message that can be sent across an HTTP connection.

Returns
Returns a String containing the generated Message.

Implemented in Mezzanine::Network::HTTPRequest, and Mezzanine::Network::HTTPResponse.

virtual Boole Mezzanine::Network::HTTPMessage::Decompose ( const String Message)
pure virtual

Populates the members of this class with data from a text HTTP Message.

Parameters
MessageThe String containing the Message to be decomposed.
Returns
Returns true if the String was successfully decomposed.

Implemented in Mezzanine::Network::HTTPRequest, and Mezzanine::Network::HTTPResponse.

virtual Boole Mezzanine::Network::HTTPMessage::Decompose ( StringIterator CurrIt,
const StringIterator  EndIt 
)
pure virtual

Populates the members of this class with data from a text HTTP Message.

Parameters
CurrItAn iterator at the start of the range to be parsed.
EndItAn iterator at the end of the range to be parsed. Parsing may or may not reach this point.
Returns
Returns true if the String was successfully decomposed.

Implemented in Mezzanine::Network::HTTPRequest, and Mezzanine::Network::HTTPResponse.

const String & Mezzanine::Network::HTTPMessage::GetBody ( ) const

Gets the message body containing additional information.

Returns
Returns a String containing the body of the message.

Definition at line 239 of file httpmessage.cpp.

const String & Mezzanine::Network::HTTPMessage::GetConnectionHeader ( ) const

Gets the Connection Header.

Returns
Returns a String containing control options for the current HTTP connection, or blank if the field is not set.

Definition at line 324 of file httpmessage.cpp.

const String & Mezzanine::Network::HTTPMessage::GetContentLengthHeader ( ) const

Gets the Content-Length Header.

Returns
Returns a String containing containing the length of the message body in bytes, or blank if the field is not set.

Definition at line 330 of file httpmessage.cpp.

const String & Mezzanine::Network::HTTPMessage::GetContentTypeHeader ( ) const

Gets the Content-Type Header.

Returns
Returns a String containing one or more descriptors on how the data in the message body is presented, such if it's plain text, XML, or a form. Can also return blank if not set.

Definition at line 336 of file httpmessage.cpp.

const String & Mezzanine::Network::HTTPMessage::GetField ( const String FieldName) const

Gets a Name-Value pair for a header field in the message.

Parameters
FieldNameThe name of the field to retrieve.
Returns
Returns a String containing the set value for the named header. If none is set or the named field does not exist then an empty String is returned.

Definition at line 263 of file httpmessage.cpp.

UInt16 Mezzanine::Network::HTTPMessage::GetHTTPMajorVersion ( ) const

Gets the major version of this message.

Returns
Returns the major version component of this message.

Definition at line 227 of file httpmessage.cpp.

UInt16 Mezzanine::Network::HTTPMessage::GetHTTPMinorVersion ( ) const

Gets the minor version of this message.

Returns
Returns the minor version component of this message.

Definition at line 233 of file httpmessage.cpp.

const SimpleVersion & Mezzanine::Network::HTTPMessage::GetHTTPVersion ( ) const

Gets both the major and minor version of this message.

Returns
Returns a const reference to a SimpleVersion containing the major and minor versions of this message.

Definition at line 218 of file httpmessage.cpp.

Whole Mezzanine::Network::HTTPMessage::GetMaxFields ( ) const

Gets how many header fields can be added to this message during parsing.

Returns
Returns a whole representing how many header fields can be parsed.

Definition at line 245 of file httpmessage.cpp.

Boole Mezzanine::Network::HTTPMessage::GetMessageComponent ( StringIterator CurrIt,
const StringIterator  EndIt,
String Component 
)
protected

Extracts all characters from CurrIt until the first space encountered or EndIt, whichever comes first.

Parameters
CurrItAn iterator to the current character being processed in the string being parsed.
EndItAn iterator to the last character in the string to be parsed.
ComponentThe string to which the extracted characters will be appended.
Returns
Returns true if the end of line was detected while parsing, false otherwise.

Definition at line 177 of file httpmessage.cpp.

Boole Mezzanine::Network::HTTPMessage::HasField ( const String FieldName) const

Checks if this message has the named header field.

Note
Fields should only ever be created when "SetField" is called, but there is no guarantee that the value for that field will be set.
Parameters
FieldNameThe name of the field to check for.
Returns
Returns true if this message has the named field, false otherwise.

Definition at line 281 of file httpmessage.cpp.

Boole Mezzanine::Network::HTTPMessage::ParseHTTPFields ( StringIterator CurrIt,
const StringIterator  EndIt 
)
protected

Parses the HTTP fields from a provided string.

Parameters
CurrItAn iterator to the current character being processed in the string being parsed.
EndItAn iterator to the last character in the string to be parsed.
Returns
Returns true if the parse was successful, false if it failed.

Definition at line 126 of file httpmessage.cpp.

virtual Boole Mezzanine::Network::HTTPMessage::ParseHTTPHeader ( StringIterator CurrIt,
const StringIterator  EndIt 
)
protectedpure virtual

Parses the information contained in the Message Header.

Parameters
CurrItAn iterator to the current character being processed in the string being parsed.
EndItAn iterator to the last character in the string to be parsed.
Returns
Returns true if the parse was successful, false if it failed.

Implemented in Mezzanine::Network::HTTPRequest, and Mezzanine::Network::HTTPResponse.

Boole Mezzanine::Network::HTTPMessage::ParseHTTPVersion ( const String ToParse)
protected

Parses the HTTP version from a provided string.

Parameters
ToParseThe String to retrieve the version information from.
Returns
Returns true if the parse was successful, false if it failed.

Definition at line 113 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::RemoveField ( const String FieldName)

Removes a specific field from this message by name.

Parameters
FieldNameThe name of the field to be removed.

Definition at line 296 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetBody ( const String Body)

Sets the message body containing additional information.

Remarks
Request bodies are optional or just unnecessary for most request methods. Be sure you need a body for your request before setting one on a request.
Parameters
BodyThe body of the message.

Definition at line 236 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetConnectionHeader ( const String Connection)

Sets the Connection Header.

Remarks
In most cases this will just specify whether the connection is expected to be closed immediately after the transaction or kept open (close vs keep-alive).
Parameters
ConnectionControl options for the current HTTP connection.

Definition at line 321 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetContentLengthHeader ( const String ContentLength)

Sets the Content-Length Header.

Remarks
This header is required any time a message body has contents and is not chunked.
Parameters
ContentLengthThe length of the message body in bytes.

Definition at line 327 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetContentTypeHeader ( const String ContentType)

Sets the Content-Type Header.

Remarks
This header is required any time a message body has contents.
Parameters
ContentTypeOne or more descriptors on how the data in the message body is presented, such if it's plain text, XML, or a form.

Definition at line 333 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetField ( const String FieldName,
const String FieldValue 
)

Sets a Name-Value pair for a header field in the message.

Parameters
FieldNameThe name of the field to be set.
FieldValueThe value to be set for the named header field.

Definition at line 248 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetHTTPMajorVersion ( const UInt16  Major)

Sets the major version of this message.

Parameters
MajorThe major portion of the version to set.

Definition at line 224 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetHTTPMinorVersion ( const UInt16  Minor)

Sets the minor version of this message.

Parameters
MinorThe minor portion of the version to set.

Definition at line 230 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetHTTPVersion ( const SimpleVersion Version)

Sets both the major and minor version of this message via SimpleVersion.

Parameters
VersionThe version to be applied to this message.

Definition at line 215 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetHTTPVersion ( const UInt16  Major,
const UInt16  Minor 
)

Sets both the major and minor version of this message.

Parameters
MajorThe major portion of the version to set.
MinorThe minor portion of the version to set.

Definition at line 221 of file httpmessage.cpp.

void Mezzanine::Network::HTTPMessage::SetMaxFields ( const Whole  MaxFields)

Sets how many header fields can be added to this message during parsing.

Remarks
Setting a sane maximum number of header fields is designed to prevent certain types of DDOS attacks on servers.
Parameters
MaxFieldsThe maximum number of header fields that can be parsed by this message. Initial value: 100.

Definition at line 242 of file httpmessage.cpp.

Member Data Documentation

Whole Mezzanine::Network::HTTPMessage::MaxHeaderFields
protected

The maximum number of allowed header fields in this message.

Definition at line 87 of file httpmessage.h.

String Mezzanine::Network::HTTPMessage::MessageBody
protected

The body of the message.

Definition at line 93 of file httpmessage.h.

HeaderFieldContainer Mezzanine::Network::HTTPMessage::MessageFields
protected

A container of fields to populate the message header with.

Definition at line 96 of file httpmessage.h.

SimpleVersion Mezzanine::Network::HTTPMessage::MessageVersion
protected

The version component for this response.

Definition at line 90 of file httpmessage.h.


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