41 #ifndef _networkhttpresponse_cpp
42 #define _networkhttpresponse_cpp
44 #include "Network/httpresponse.h"
46 #include "stringtool.h"
57 Converter << std::hex << ToConvert;
97 while( CurrIt != EndIt )
99 if( (*CurrIt) ==
'\r' ) {
101 }
else if( (*CurrIt) ==
'\n' ) {
122 for( HeaderFieldContainer::const_iterator FieldIt = this->
MessageFields.begin() ; FieldIt != this->
MessageFields.end() ; ++FieldIt )
124 ResponseStream << (*FieldIt).HeaderName <<
": " << (*FieldIt).HeaderValue <<
"\r\n";
126 ResponseStream <<
"\r\n";
129 return ResponseStream.str();
135 return this->
Decompose(CurrIt,Message.end());
140 if( CurrIt != EndIt ) {
151 if( this->
GetField(
"transfer-encoding") !=
"chunked" ) {
153 if( !Length.empty() ) {
160 size_t ChunkLength = ConvertToWholeHex(ChunkSizeStr);
161 while( ChunkLength != 0 )
164 while( (*CurrIt) !=
'\r' && CurrIt != EndIt )
170 ChunkSizeStr.clear();
172 ChunkLength = ConvertToWholeHex(ChunkSizeStr);
207 { this->
SetField(
"Content-Encoding",ContentEncoding); }
210 {
return this->
GetField(
"Content-Encoding"); }
219 { this->
SetField(
"Server",Server); }
222 {
return this->
GetField(
"Server"); }
String::const_iterator StringIterator
Convenience typedef for String iterators.
String ResponseDescription
The textual message delivered to explain the status code.
Boole ParseHTTPFields(StringIterator &CurrIt, const StringIterator EndIt)
Parses the HTTP fields from a provided string.
bool Boole
Generally acts a single bit, true or false.
const String & GetAllowHeader() const
Gets the Allow Header.
const String & GetServerHeader() const
Gets the Server Header.
void SetAllowHeader(const String &Allow)
Sets the Allow Header.
UInt16 Major
The Major component of the version to be expressed.
Used for internal error conditions, not an actual status code.
const String & GetField(const String &FieldName) const
Gets a Name-Value pair for a header field in the message.
Boole Decompose(const String &Message)
Populates the members of this class with data from a text HTTP Message.
std::stringstream StringStream
A Datatype used for streaming operations with strings.
SimpleVersion MessageVersion
The version component for this response.
UInt16 Minor
The Minor component of the version to be expressed.
void SetStatusCode(const Whole Code)
Sets the status code explaining the result of a HTTP request.
Boole GetMessageComponent(StringIterator &CurrIt, const StringIterator EndIt, String &Component)
Extracts all characters from CurrIt until the first space encountered or EndIt, whichever comes first...
const String & GetContentLengthHeader() const
Gets the Content-Length Header.
void SetField(const String &FieldName, const String &FieldValue)
Sets a Name-Value pair for a header field in the message.
~HTTPResponse()
Class destructor.
Boole ParseHTTPHeader(StringIterator &CurrIt, const StringIterator EndIt)
Parses the information contained in the Message Header.
const String & GetResponseDescription() const
Gets the textual description to explain the status code contained in the response.
Whole ResponseCode
The HTTP method to use for the response.
Whole GetStatusCode() const
Gets the status code explaining the result of a HTTP request.
void SetDateHeader(const String &Date)
Sets the Date Header.
Boole ParseHTTPVersion(const String &ToParse)
Parses the HTTP version from a provided string.
const String & GetContentEncodingHeader() const
Gets the Content-Encoding Header.
The bulk of the engine components go in this namspace.
HeaderFieldContainer MessageFields
A container of fields to populate the message header with.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
String MessageBody
The body of the message.
void SetContentEncodingHeader(const String &ContentEncoding)
Sets the Content-Encoding Header.
String Compose() const
Creates a completed Message that can be sent across an HTTP connection.
void SetResponseDescription(const String &Message)
Sets the textual description to explain the status code contained in the response.
HTTPResponse()
Class constructor.
std::string String
A datatype used to a series of characters.
const String & GetDateHeader() const
Gets the Date Header.
void SetServerHeader(const String &Server)
Sets the Server Header.