FIX::HttpMessage Class Reference

HTTP Message that implemented GET functionality. More...

`#include <HttpMessage.h>`

## Public Types

typedef std::map< std::string, std::string > | Parameters

## Public Member Functions

| HttpMessage ()
| HttpMessage (const std::string &string) throw ( InvalidMessage )
| Construct a message from a string. More...
| HttpMessage (const HttpMessage &copy)
std::string | toString () const
| Get a string representation of the message. More...
std::string & | toString (std::string &) const
| Get a string representation without making a copy. More...
void | setString (const std::string &string) throw ( InvalidMessage )
void | clear ()
const std::string & | getRootString () const
const std::string | getParameterString () const
const Parameters & | getParameters () const
bool | hasParameter (const std::string &key) const
const std::string & | getParameter (const std::string &key) const throw ( std::logic_error )
void | addParameter (const std::string &key, const std::string &value)
void | removeParameter (const std::string &key)

## Static Public Member Functions

static std::string | createResponse (int error=0, const std::string &text="")

## Private Attributes

std::string | m_root
Parameters | m_parameters

## Detailed Description

HTTP Message that implemented GET functionality.

Definition at line 54 of file HttpMessage.h.

## Member Typedef Documentation

## Parameters

typedef std::map<std::string, std::string> FIX::HttpMessage::Parameters

Definition at line 74 of file HttpMessage.h.

## Constructor & Destructor Documentation

## HttpMessage() [1/3]

FIX::HttpMessage::HttpMessage | ( |  | ) |

Definition at line 51 of file HttpMessage.cpp.

## HttpMessage() [2/3]

FIX::HttpMessage::HttpMessage | ( | const std::string & | string | ) |
throw | ( | InvalidMessage
| ) |  |

Construct a message from a string.

Definition at line 53 of file HttpMessage.cpp.

{
clear();

## HttpMessage() [3/3]

FIX::HttpMessage::HttpMessage | ( | const HttpMessage & | copy | ) |

inline

Definition at line 82 of file HttpMessage.h.

: "&";
result += i->first + "=" + i->second;
}
return result;
}

## Member Function Documentation

## addParameter()

void FIX::HttpMessage::addParameter | ( | const std::string & | key,
|  | const std::string & | value
| ) |  |

inline

Definition at line 140 of file HttpMessage.h.

## clear()

void FIX::HttpMessage::clear | ( |  | ) |

inline

Definition at line 97 of file HttpMessage.h.

{
Parameters::const_iterator find = m_parameters.find( key );
if( find == m_parameters.end() )
throw std::logic_error( "Parameter " + key + " not found" );
return find->second;
}

References m_parameters.

## createResponse()

std::string FIX::HttpMessage::createResponse | ( | int | error = `0`,
|  | const std::string & | text = `""`
| ) |  |

static

Definition at line 103 of file HttpMessage.cpp.

: errorString = "See Other"; break;
case 304: errorString = "Not Modified"; break;
case 305: errorString = "Use Proxy"; break;
case 307: errorString = "Temporary Redirect"; break;
case 400: errorString = "Bad Request"; break;
case 401: errorString = "Unauthorized"; break;
case 402: errorString = "Payment Required"; break;
case 403: errorString = "Forbidden"; break;
case 404: errorString = "Not Found"; break;
case 405: errorString = "Method Not Allowed"; break;
case 406: errorString = "Not Acceptable"; break;
case 407: errorString = "Proxy Authentication Required"; break;
case 408: errorString = "Request Timeout"; break;
case 409: errorString = "Conflict"; break;
case 410: errorString = "Gone"; break;
case 411: errorString = "Length Required"; break;
case 412: errorString = "Precondition Failed"; break;
case 413: errorString = "Request Entity Too Large"; break;
case 414: errorString = "Request-URI Too Large"; break;
case 415: errorString = "Unsupported Media Type"; break;
case 416: errorString = "Requested Range Not Satisfiable"; break;
case 417: errorString = "Expectation Failed"; break;
case 500: errorString = "Internal Server Error"; break;
case 501: errorString = "Not Implemented"; break;
case 502: errorString = "Bad Gateway"; break;
case 503: errorString = "Service Unavailable"; break;
case 504: errorString = "Gateway Timeout"; break;
case 505: errorString = "HTTP Version not supported"; break;
default: errorString = "Unknown";
}
std::stringstream response;
response << "HTTP/1.1 " << error << " " << errorString << "\r\n"
<< "Server: QuickFIX" << "\r\n"
<< "Content-Type: text/html; charset=iso-8859-1" << "\r\n\r\n"
<< "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">";
if( error < 200 || error >= 300 )
response << "<HTML><HEAD><TITLE>" << error << " " << errorString << "</TITLE></HEAD><BODY>"
<< "<H1>" << error << " " << errorString << "</H1>" << text << "</BODY></HTML>";
else
response << text;
return response.str();
}
}

Referenced by FIX::HttpConnection::disconnect(), and FIX::HttpConnection::processRequest().

## getParameter()

const std::string& FIX::HttpMessage::getParameter | ( | const std::string & | key | ) | const
throw | ( | std::logic_error
| ) |  |

inline

Definition at line 131 of file HttpMessage.h.

Referenced by FIX::HttpConnection::processDisableSessions(), FIX::HttpConnection::processEnableSessions(), FIX::HttpConnection::processRefreshSession(), FIX::HttpConnection::processRefreshSessions(), FIX::HttpConnection::processResetSession(), FIX::HttpConnection::processResetSessions(), and FIX::HttpConnection::processSession().

## getParameters()

const Parameters& FIX::HttpMessage::getParameters | ( |  | ) | const

inline

Definition at line 122 of file HttpMessage.h.

## getParameterString()

const std::string FIX::HttpMessage::getParameterString | ( |  | ) | const

inline

Definition at line 110 of file HttpMessage.h.

{
m_parameters.erase( key );
}
static std::string createResponse( int error = 0, const std::string& text = "" );
private:
std::string m_root;
Parameters m_parameters;

References m_parameters.

Referenced by FIX::HttpConnection::processRefreshSession(), FIX::HttpConnection::processResetSession(), FIX::HttpConnection::processRoot(), and FIX::HttpConnection::processSession().

## getRootString()

const std::string& FIX::HttpMessage::getRootString | ( |  | ) | const

inline

Definition at line 107 of file HttpMessage.h.

{
m_parameters[key] = value;

References m_parameters.

Referenced by FIX::HttpConnection::processRequest().

## hasParameter()

bool FIX::HttpMessage::hasParameter | ( | const std::string & | key | ) | const

inline

Definition at line 125 of file HttpMessage.h.

{
std::string str;
stream << message.toString( str );
return stream;

Referenced by FIX::HttpConnection::processDisableSessions(), FIX::HttpConnection::processEnableSessions(), FIX::HttpConnection::processRefreshSession(), FIX::HttpConnection::processRefreshSessions(), FIX::HttpConnection::processResetSession(), FIX::HttpConnection::processResetSessions(), and FIX::HttpConnection::processSession().

## removeParameter()

void FIX::HttpMessage::removeParameter | ( | const std::string & | key | ) |

inline

Definition at line 145 of file HttpMessage.h.

Referenced by FIX::HttpConnection::processDisableSessions(), FIX::HttpConnection::processEnableSessions(), FIX::HttpConnection::processRefreshSession(), FIX::HttpConnection::processRefreshSessions(), FIX::HttpConnection::processResetSession(), FIX::HttpConnection::processResetSessions(), and FIX::HttpConnection::processSession().

## setString()

void FIX::HttpMessage::setString | ( | const std::string & | string | ) |
throw | ( | InvalidMessage
| ) |  |

Definition at line 71 of file HttpMessage.cpp.

{
std::string::size_type sepPos = parameters.find_first_of( "=", paramPos );
if( sepPos == std::string::npos ) break;
std::string::size_type tempPos = paramPos;
paramPos = parameters.find_first_of( "&", paramPos + 1 );
std::string key = parameters.substr(tempPos + 1, sepPos - tempPos - 1);
std::string value = parameters.substr(sepPos + 1, paramPos - sepPos - 1);
m_parameters[key] = value;
}
}
std::string HttpMessage::createResponse( int error, const std::string& text )
{
std::string errorString;
switch( error )
{
case 100: errorString = "Continue"; break;
case 101: errorString = "Switching Protocols"; break;
case 200: errorString = "OK"; break;
case 201: errorString = "Created"; break;
case 202: errorString = "Accepted"; break;
case 203: errorString = "Non-Authoritative Information"; break;
case 204: errorString = "No Content"; break;
case 205: errorString = "Reset Content"; break;
case 206: errorString = "Partial Content"; break;
case 300: errorString = "Multiple Choices"; break;
case 301: errorString = "Moved Permanently"; break;

## toString() [1/2]

std::string FIX::HttpMessage::toString | ( |  | ) | const

Get a string representation of the message.

Definition at line 59 of file HttpMessage.cpp.

Referenced by FIX::HttpConnection::processDisableSessions(), FIX::HttpConnection::processEnableSessions(), FIX::HttpConnection::processRefreshSession(), FIX::HttpConnection::processRefreshSessions(), FIX::HttpConnection::processRequest(), FIX::HttpConnection::processResetSession(), FIX::HttpConnection::processResetSessions(), and FIX::HttpConnection::processSession().

## toString() [2/2]

std::string & FIX::HttpMessage::toString | ( | std::string & | str | ) | const

Get a string representation without making a copy.

Definition at line 65 of file HttpMessage.cpp.

## Member Data Documentation

## m_parameters

Parameters FIX::HttpMessage::m_parameters

private

Definition at line 154 of file HttpMessage.h.

Referenced by clear(), getParameterString(), and getRootString().

## m_root

std::string FIX::HttpMessage::m_root

private

Definition at line 153 of file HttpMessage.h.

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

- HttpMessage.h
- HttpMessage.cpp

FIX::HttpMessage::m_parameters
Parameters m_parameters
Definition: HttpMessage.h:154
FIX::HttpMessage::createResponse
static std::string createResponse(int error=0, const std::string &text="")
Definition: HttpMessage.cpp:103
FIX::HttpMessage::clear
void clear()
Definition: HttpMessage.h:97
FIX::HttpMessage::Parameters
std::map< std::string, std::string > Parameters
Definition: HttpMessage.h:74
FIX::HttpMessage::m_root
std::string m_root
Definition: HttpMessage.h:153