FIX::HttpConnection Class Reference

Encapsulates a HTTP socket file descriptor. More...

`#include <HttpConnection.h>`

Collaboration diagram for FIX::HttpConnection:
[legend]

## Public Member Functions

| HttpConnection (int s)
int | getSocket () const
bool | read ()

## Private Member Functions

bool | readMessage (std::string &msg) throw ( SocketRecvFailed )
void | processStream ()
void | processRequest (const HttpMessage &)
void | processRoot (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processResetSessions (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processRefreshSessions (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processEnableSessions (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processDisableSessions (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processSession (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processResetSession (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | processRefreshSession (const HttpMessage &, std::stringstream &h, std::stringstream &b)
void | showToggle (std::stringstream &s, const std::string &name, bool value, const std::string &url)
void | showRow (std::stringstream &s, const std::string &name, bool value, const std::string &url="")
void | showRow (std::stringstream &s, const std::string &name, const std::string &value, const std::string &url="")
void | showRow (std::stringstream &s, const std::string &name, int value, const std::string &url="")
bool | send (const std::string &)
void | disconnect (int error=0)

## Private Attributes

int | m_socket
char | m_buffer [BUFSIZ]
HttpParser | m_parser
fd_set | m_fds

## Detailed Description

Encapsulates a HTTP socket file descriptor.

Definition at line 54 of file HttpConnection.h.

## Constructor & Destructor Documentation

## HttpConnection()

FIX::HttpConnection::HttpConnection | ( | int | s | ) |

Definition at line 36 of file HttpConnection.cpp.

: m_socket( s )
{
FD_ZERO( &m_fds );
FD_SET( m_socket, &m_fds );
}

References m_fds, and m_socket.

## Member Function Documentation

## disconnect()

void FIX::HttpConnection::disconnect | ( | int | error = `0` | ) |

private

Definition at line 48 of file HttpConnection.cpp.

{
if( error > 0 )
send( HttpMessage::createResponse(error) );
socket_close( m_socket );
}

References FIX::HttpMessage::createResponse(), m_socket, send(), and FIX::socket_close().

Referenced by processRequest(), processStream(), and read().

## getSocket()

int FIX::HttpConnection::getSocket | ( |  | ) | const

inline

Definition at line 59 of file HttpConnection.h.

## processDisableSessions()

void FIX::HttpConnection::processDisableSessions | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 375 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
std::set<SessionID> sessions = Session::getSessions();
std::set<SessionID>::iterator session;
for( session = sessions.begin(); session != sessions.end(); ++session )
Session::lookupSession( *session )->logout();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/").text("Sessions"); }
b << " have been disabled";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to disable all sessions ?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "?confirm=1").text("YES, disable sessions"); }
b << "]" << NBSP << "[";
{ A a(b); a.href("/").text("NO, do not disable sessions"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::Session::getSessions(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::logout(), FIX::Session::lookupSession(), HTML::NBSP, FIX::HttpMessage::removeParameter(), HTML::TAG::text(), and FIX::HttpMessage::toString().

Referenced by processRequest().

## processEnableSessions()

void FIX::HttpConnection::processEnableSessions | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 328 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
std::set<SessionID> sessions = Session::getSessions();
std::set<SessionID>::iterator session;
for( session = sessions.begin(); session != sessions.end(); ++session )
Session::lookupSession( *session )->logon();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/").text("Sessions"); }
b << " have been enabled";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to enable all sessions ?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "?confirm=1").text("YES, enable sessions"); }
b << "]" << NBSP << "[";
{ A a(b); a.href("/").text("NO, do not enable sessions"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::Session::getSessions(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::logon(), FIX::Session::lookupSession(), HTML::NBSP, FIX::HttpMessage::removeParameter(), HTML::TAG::text(), and FIX::HttpMessage::toString().

Referenced by processRequest().

## processRefreshSession()

void FIX::HttpConnection::processRefreshSession | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 617 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
std::string beginString = request.getParameter( "BeginString" );
std::string senderCompID = request.getParameter( "SenderCompID" );
std::string targetCompID = request.getParameter( "TargetCompID" );
std::string sessionQualifier;
if( copy.hasParameter("SessionQualifier") )
sessionQualifier = copy.getParameter( "SessionQualifier" );
SessionID sessionID( beginString, senderCompID, targetCompID, sessionQualifier );
Session* pSession = Session::lookupSession( sessionID );
if( pSession == 0 ) throw SessionNotFound();
std::string sessionUrl = "/session" + request.getParameterString();
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
pSession->refresh();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/session" << copy.getParameterString() << "'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/session" + copy.getParameterString()).text(sessionID.toString()); }
b << " has been refreshed";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to refresh session ";
{ A a(b); a.href(sessionUrl + request.getParameterString()).text(sessionID.toString()); }
b << "?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "&confirm=1").text("YES, refresh session"); }
b << "]" << NBSP << "[";
{ A a(b); a.href(sessionUrl).text("NO, do not refresh session"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::HttpMessage::getParameterString(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::lookupSession(), HTML::NBSP, FIX::Session::refresh(), FIX::HttpMessage::removeParameter(), HTML::TAG::text(), FIX::HttpMessage::toString(), and FIX::SessionID::toString().

Referenced by processRequest().

## processRefreshSessions()

void FIX::HttpConnection::processRefreshSessions | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 281 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
std::set<SessionID> sessions = Session::getSessions();
std::set<SessionID>::iterator session;
for( session = sessions.begin(); session != sessions.end(); ++session )
Session::lookupSession( *session )->refresh();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/").text("Sessions"); }
b << " have been refreshed";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to refresh all sessions ?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "?confirm=1").text("YES, refresh sessions"); }
b << "]" << NBSP << "[";
{ A a(b); a.href("/").text("NO, do not refresh sessions"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::Session::getSessions(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::lookupSession(), HTML::NBSP, FIX::Session::refresh(), FIX::HttpMessage::removeParameter(), HTML::TAG::text(), and FIX::HttpMessage::toString().

Referenced by processRequest().

## processRequest()

void FIX::HttpConnection::processRequest | ( | const HttpMessage & | request | ) |

private

Definition at line 126 of file HttpConnection.cpp.

{
int error = 200;
std::stringstream h;
std::stringstream b;
std::string titleString = "QuickFIX Engine Web Interface";
{ HEAD head(h); head.text();
{ CENTER center(h); center.text();
{ TITLE title(h); title.text(titleString); }
{ H1 h1(h); h1.text(titleString); }
}
{ CENTER center(h); center.text();
{ A a(h); a.href("/").text("HOME"); }
h << NBSP;
{ A a(h); a.href(request.toString()).text("RELOAD"); }
}
HR hr(h); hr.text();
}
BODY body(b); body.text();
try
{
if( request.getRootString() == "/" )
processRoot( request, h, b );
else if( request.getRootString() == "/resetSessions" )
processResetSessions( request, h, b );
else if( request.getRootString() == "/refreshSessions" )
processRefreshSessions( request, h, b );
else if( request.getRootString() == "/enableSessions" )
processEnableSessions( request, h, b );
else if( request.getRootString() == "/disableSessions" )
processDisableSessions( request, h, b );
else if( request.getRootString() == "/session" )
processSession( request, h, b );
else if( request.getRootString() == "/resetSession" )
processResetSession( request, h, b );
else if( request.getRootString() == "/refreshSession" )
processRefreshSession( request, h, b );
else
error = 404;
}
catch( std::exception& e )
{
error = 400;
b << e.what();
}
std::string response = "<HTML>" + h.str() + b.str() + "</HTML>";
send( HttpMessage::createResponse(error, error == 200 ? response : "") );
disconnect();
}

References FIX::HttpMessage::createResponse(), disconnect(), FIX::HttpMessage::getRootString(), HTML::A::href(), HTML::NBSP, processDisableSessions(), processEnableSessions(), processRefreshSession(), processRefreshSessions(), processResetSession(), processResetSessions(), processRoot(), processSession(), send(), HTML::TAG::text(), and FIX::HttpMessage::toString().

Referenced by processStream().

## processResetSession()

void FIX::HttpConnection::processResetSession | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 559 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
std::string beginString = request.getParameter( "BeginString" );
std::string senderCompID = request.getParameter( "SenderCompID" );
std::string targetCompID = request.getParameter( "TargetCompID" );
std::string sessionQualifier;
if( copy.hasParameter("SessionQualifier") )
sessionQualifier = copy.getParameter( "SessionQualifier" );
SessionID sessionID( beginString, senderCompID, targetCompID, sessionQualifier );
Session* pSession = Session::lookupSession( sessionID );
if( pSession == 0 ) throw SessionNotFound();
std::string sessionUrl = "/session" + request.getParameterString();
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
pSession->reset();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/session" << copy.getParameterString() << "'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/session" + copy.getParameterString()).text(sessionID.toString()); }
b << " has been reset";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to reset session ";
{ A a(b); a.href(sessionUrl + request.getParameterString()).text(sessionID.toString()); }
b << "?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "&confirm=1").text("YES, reset session"); }
b << "]" << NBSP << "[";
{ A a(b); a.href(sessionUrl).text("NO, do not reset session"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::HttpMessage::getParameterString(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::lookupSession(), HTML::NBSP, FIX::HttpMessage::removeParameter(), FIX::Session::reset(), HTML::TAG::text(), FIX::HttpMessage::toString(), and FIX::SessionID::toString().

Referenced by processRequest().

## processResetSessions()

void FIX::HttpConnection::processResetSessions | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 234 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
bool confirm = false;
if( copy.hasParameter("confirm") && copy.getParameter("confirm") != "0" )
{
confirm = true;
std::set<SessionID> sessions = Session::getSessions();
std::set<SessionID>::iterator session;
for( session = sessions.begin(); session != sessions.end(); ++session )
Session::lookupSession( *session )->reset();
copy.removeParameter("confirm");
}
if( confirm )
{
h << "<META http-equiv='refresh' content=2;URL='" << "/'>";
CENTER center(b); center.text();
H2 h2(b); h2.text();
{ A a(b); a.href("/").text("Sessions"); }
b << " have been reset";
}
else
{
{ CENTER center(b); center.text();
H2 h2(b); h2.text();
b << "Are you sure you want to reset all sessions ?";
}
{ CENTER center(b); center.text();
b << "[";
{ A a(b); a.href(request.toString() + "?confirm=1").text("YES, reset sessions"); }
b << "]" << NBSP << "[";
{ A a(b); a.href("/").text("NO, do not reset sessions"); }
b << "]";
}
}
}
catch( std::exception& e )
{
b << e.what();
}
}

References FIX::HttpMessage::getParameter(), FIX::Session::getSessions(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::lookupSession(), HTML::NBSP, FIX::HttpMessage::removeParameter(), FIX::Session::reset(), HTML::TAG::text(), and FIX::HttpMessage::toString().

Referenced by processRequest().

## processRoot()

void FIX::HttpConnection::processRoot | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 182 of file HttpConnection.cpp.

{
TABLE table(b); table.border(1).cellspacing(2).width(100).text();
{ CAPTION caption(b); caption.text();
EM em(b); em.text();
b << Session::numSessions() << " Sessions managed by QuickFIX";
{ HR hr(b); hr.text(); }
{ b << NBSP; A a(b); a.href("/resetSessions" + request.getParameterString()).text("RESET"); }
{ b << NBSP; A a(b); a.href("/refreshSessions" + request.getParameterString()).text("REFRESH"); }
{ b << NBSP; A a(b); a.href("/enableSessions" + request.getParameterString()).text("ENABLE"); }
{ b << NBSP; A a(b); a.href("/disableSessions" + request.getParameterString()).text("DISABLE"); }
}
{ TR tr(b); tr.text();
{ TD td(b); td.align("center").text("Session"); }
{ TD td(b); td.align("center").text("ConnectionType"); }
{ TD td(b); td.align("center").text("Enabled"); }
{ TD td(b); td.align("center").text("Session Time"); }
{ TD td(b); td.align("center").text("Logged On"); }
{ TD td(b); td.align("center").text("Next Incoming"); }
{ TD td(b); td.align("center").text("Next Outgoing"); }
}
std::set<SessionID> sessions = Session::getSessions();
std::set<SessionID>::iterator i;
for( i = sessions.begin(); i != sessions.end(); ++i )
{
Session* pSession = Session::lookupSession( *i );
if( !pSession ) continue;
{ TR tr(b); tr.text();
{ TD td(b); td.text();
std::string href = "/session?BeginString=" + i->getBeginString().getValue() +
"&SenderCompID=" + i->getSenderCompID().getValue() +
"&TargetCompID=" + i->getTargetCompID().getValue();
if( i->getSessionQualifier().size() )
href += "&SessionQualifier=" + i->getSessionQualifier();
A a(b); a.href(href).text(i->toString());
}
{ TD td(b); td.text(pSession->isInitiator() ? "initiator" : "acceptor"); }
{ TD td(b); td.text(pSession->isEnabled() ? "yes" : "no"); }
{ TD td(b); td.text(pSession->isSessionTime(UtcTimeStamp()) ? "yes" : "no"); }
{ TD td(b); td.text(pSession->isLoggedOn() ? "yes" : "no"); }
{ TD td(b); td.text(pSession->getExpectedTargetNum()); }
{ TD td(b); td.text(pSession->getExpectedSenderNum()); }
}
}
}

References HTML::TD::align(), HTML::TABLE::border(), HTML::TABLE::cellspacing(), FIX::Session::getExpectedSenderNum(), FIX::Session::getExpectedTargetNum(), FIX::HttpMessage::getParameterString(), FIX::Session::getSessions(), HTML::A::href(), FIX::Session::isEnabled(), FIX::Session::isInitiator(), FIX::Session::isLoggedOn(), FIX::Session::isSessionTime(), FIX::Session::lookupSession(), HTML::NBSP, FIX::Session::numSessions(), HTML::TAG::text(), and HTML::TABLE::width().

Referenced by processRequest().

## processSession()

void FIX::HttpConnection::processSession | ( | const HttpMessage & | request,
|  | std::stringstream & | h,
|  | std::stringstream & | b
| ) |  |

private

Definition at line 422 of file HttpConnection.cpp.

{
try
{
HttpMessage copy = request;
std::string url = request.toString();
std::string beginString = copy.getParameter( "BeginString" );
std::string senderCompID = copy.getParameter( "SenderCompID" );
std::string targetCompID = copy.getParameter( "TargetCompID" );
std::string sessionQualifier;
if( copy.hasParameter("SessionQualifier") )
sessionQualifier = copy.getParameter( "SessionQualifier" );
SessionID sessionID( beginString, senderCompID, targetCompID, sessionQualifier );
Session* pSession = Session::lookupSession( sessionID );
if( pSession == 0 ) throw SessionNotFound();
if( copy.hasParameter("Enabled") )
{
copy.getParameter("Enabled") == "0" ? pSession->logout() : pSession->logon();
copy.removeParameter("Enabled");
}
if( copy.hasParameter("Next%20Incoming") )
{
int value = IntConvertor::convert( copy.getParameter("Next%20Incoming") );
pSession->setNextTargetMsgSeqNum( value <= 0 ? 1 : value );
copy.removeParameter("Next%20Incoming");
}
if( copy.hasParameter("Next%20Outgoing") )
{
int value = IntConvertor::convert( copy.getParameter("Next%20Outgoing") );
pSession->setNextSenderMsgSeqNum( value <= 0 ? 1 : value );
copy.removeParameter("Next%20Outgoing");
}
if( copy.hasParameter(SEND_REDUNDANT_RESENDREQUESTS) )
{
pSession->setSendRedundantResendRequests( copy.getParameter(SEND_REDUNDANT_RESENDREQUESTS) != "0" );
copy.removeParameter(SEND_REDUNDANT_RESENDREQUESTS);
}
if( copy.hasParameter(CHECK_COMPID) )
{
pSession->setCheckCompId( copy.getParameter(CHECK_COMPID) != "0" );
copy.removeParameter(CHECK_COMPID);
}
if( copy.hasParameter(CHECK_LATENCY) )
{
pSession->setCheckLatency( copy.getParameter(CHECK_LATENCY) != "0" );
copy.removeParameter(CHECK_LATENCY);
}
if( copy.hasParameter(MAX_LATENCY) )
{
int value = IntConvertor::convert( copy.getParameter(MAX_LATENCY) );
pSession->setMaxLatency( value <= 0 ? 1 : value );
copy.removeParameter(MAX_LATENCY);
}
if( copy.hasParameter(LOGON_TIMEOUT) )
{
int value = IntConvertor::convert( copy.getParameter(LOGON_TIMEOUT) );
pSession->setLogonTimeout( value <= 0 ? 1 : value );
copy.removeParameter(LOGON_TIMEOUT);
}
if( copy.hasParameter(LOGOUT_TIMEOUT) )
{
int value = IntConvertor::convert( copy.getParameter(LOGOUT_TIMEOUT) );
pSession->setLogoutTimeout( value <= 0 ? 1 : value );
copy.removeParameter(LOGOUT_TIMEOUT);
}
if( copy.hasParameter(RESET_ON_LOGON) )
{
pSession->setResetOnLogon( copy.getParameter(RESET_ON_LOGON) != "0" );
copy.removeParameter(RESET_ON_LOGON);
}
if( copy.hasParameter(RESET_ON_LOGOUT) )
{
pSession->setResetOnLogout( copy.getParameter(RESET_ON_LOGOUT) != "0" );
copy.removeParameter(RESET_ON_LOGOUT);
}
if( copy.hasParameter(RESET_ON_DISCONNECT) )
{
pSession->setResetOnDisconnect( copy.getParameter(RESET_ON_DISCONNECT) != "0" );
copy.removeParameter(RESET_ON_DISCONNECT);
}
if( copy.hasParameter(REFRESH_ON_LOGON) )
{
pSession->setRefreshOnLogon( copy.getParameter(REFRESH_ON_LOGON) != "0" );
copy.removeParameter(REFRESH_ON_LOGON);
}
if( copy.hasParameter(MILLISECONDS_IN_TIMESTAMP) )
{
pSession->setMillisecondsInTimeStamp( copy.getParameter(MILLISECONDS_IN_TIMESTAMP) != "0" );
copy.removeParameter(MILLISECONDS_IN_TIMESTAMP);
}
if( copy.hasParameter(PERSIST_MESSAGES) )
{
pSession->setPersistMessages( copy.getParameter(PERSIST_MESSAGES) != "0" );
copy.removeParameter(PERSIST_MESSAGES);
}
if( url != copy.toString() )
h << "<META http-equiv='refresh' content=0;URL='" << copy.toString() << "'>";
TABLE table(b); table.border(1).cellspacing(2).width(100).text();
{ CAPTION caption(b); caption.text();
EM em(b); em.text();
b << sessionID;
{ HR hr(b); hr.text(); }
{ b << NBSP; A a(b); a.href("/resetSession" + copy.getParameterString()).text("RESET"); }
{ b << NBSP; A a(b); a.href("/refreshSession" + copy.getParameterString()).text("REFRESH"); }
}
showRow( b, "Enabled", pSession->isEnabled(), url );
showRow( b, "ConnectionType", std::string(pSession->isInitiator() ?"initiator" : "acceptor") );
showRow( b, "SessionTime", pSession->isSessionTime(UtcTimeStamp()) );
showRow( b, "Logged On", pSession->isLoggedOn() );
showRow( b, "Next Incoming", (int)pSession->getExpectedTargetNum(), url );
showRow( b, "Next Outgoing", (int)pSession->getExpectedSenderNum(), url );
showRow( b, SEND_REDUNDANT_RESENDREQUESTS, pSession->getSendRedundantResendRequests(), url );
showRow( b, CHECK_COMPID, pSession->getCheckCompId(), url );
showRow( b, CHECK_LATENCY, pSession->getCheckLatency(), url );
showRow( b, MAX_LATENCY, pSession->getMaxLatency(), url );
showRow( b, LOGON_TIMEOUT, pSession->getLogonTimeout(), url );
showRow( b, LOGOUT_TIMEOUT, pSession->getLogoutTimeout(), url );
showRow( b, RESET_ON_LOGON, pSession->getResetOnLogon(), url );
showRow( b, RESET_ON_LOGOUT, pSession->getResetOnLogout(), url );
showRow( b, RESET_ON_DISCONNECT, pSession->getResetOnDisconnect(), url );
showRow( b, REFRESH_ON_LOGON, pSession->getRefreshOnLogon(), url );
showRow( b, MILLISECONDS_IN_TIMESTAMP, pSession->getMillisecondsInTimeStamp(), url );
showRow( b, PERSIST_MESSAGES, pSession->getPersistMessages(), url );
}
catch( std::exception& e )
{
b << e.what();
}
}

References HTML::TABLE::border(), HTML::TABLE::cellspacing(), FIX::CHECK_COMPID, FIX::CHECK_LATENCY, FIX::IntConvertor::convert(), FIX::Session::getCheckCompId(), FIX::Session::getCheckLatency(), FIX::Session::getExpectedSenderNum(), FIX::Session::getExpectedTargetNum(), FIX::Session::getLogonTimeout(), FIX::Session::getLogoutTimeout(), FIX::Session::getMaxLatency(), FIX::Session::getMillisecondsInTimeStamp(), FIX::HttpMessage::getParameter(), FIX::HttpMessage::getParameterString(), FIX::Session::getPersistMessages(), FIX::Session::getRefreshOnLogon(), FIX::Session::getResetOnDisconnect(), FIX::Session::getResetOnLogon(), FIX::Session::getResetOnLogout(), FIX::Session::getSendRedundantResendRequests(), FIX::HttpMessage::hasParameter(), HTML::A::href(), FIX::Session::isEnabled(), FIX::Session::isInitiator(), FIX::Session::isLoggedOn(), FIX::Session::isSessionTime(), FIX::Session::logon(), FIX::LOGON_TIMEOUT, FIX::Session::logout(), FIX::LOGOUT_TIMEOUT, FIX::Session::lookupSession(), FIX::MAX_LATENCY, FIX::MILLISECONDS_IN_TIMESTAMP, HTML::NBSP, FIX::PERSIST_MESSAGES, FIX::REFRESH_ON_LOGON, FIX::HttpMessage::removeParameter(), FIX::RESET_ON_DISCONNECT, FIX::RESET_ON_LOGON, FIX::RESET_ON_LOGOUT, FIX::SEND_REDUNDANT_RESENDREQUESTS, FIX::Session::setCheckCompId(), FIX::Session::setCheckLatency(), FIX::Session::setLogonTimeout(), FIX::Session::setLogoutTimeout(), FIX::Session::setMaxLatency(), FIX::Session::setMillisecondsInTimeStamp(), FIX::Session::setNextSenderMsgSeqNum(), FIX::Session::setNextTargetMsgSeqNum(), FIX::Session::setPersistMessages(), FIX::Session::setRefreshOnLogon(), FIX::Session::setResetOnDisconnect(), FIX::Session::setResetOnLogon(), FIX::Session::setResetOnLogout(), FIX::Session::setSendRedundantResendRequests(), HTML::TAG::text(), FIX::HttpMessage::toString(), and HTML::TABLE::width().

Referenced by processRequest().

## processStream()

void FIX::HttpConnection::processStream | ( |  | ) |

private

Definition at line 107 of file HttpConnection.cpp.

{
std::string msg;
try
{
if( !readMessage(msg) )
return;
HttpMessage request( msg );
processRequest( request );
}
catch( InvalidMessage& )
{
disconnect( 400 );
return;
}
return;
}

References disconnect(), processRequest(), and readMessage().

Referenced by read().

## read()

bool FIX::HttpConnection::read | ( |  | ) |

Definition at line 56 of file HttpConnection.cpp.

{
struct timeval timeout = { 2, 0 };
fd_set readset = m_fds;
try
{
// Wait for input (1 second timeout)
int result = select( 1 + m_socket, &readset, 0, 0, &timeout );
if( result > 0 ) // Something to read
{
// We can read without blocking
ssize_t size = socket_recv( m_socket, m_buffer, sizeof(m_buffer) );
if ( size <= 0 ) { throw SocketRecvFailed( size ); }
m_parser.addToStream( m_buffer, size );
}
else if( result == 0 ) // Timeout
{
disconnect( 408 );
return false;
}
else if( result < 0 ) // Error
{
throw SocketRecvFailed( result );
}
processStream();
return true;
}
catch ( SocketRecvFailed& )
{
disconnect();
return false;
}
}

References FIX::HttpParser::addToStream(), disconnect(), m_buffer, m_fds, m_parser, m_socket, processStream(), and FIX::socket_recv().

## readMessage()

bool FIX::HttpConnection::readMessage | ( | std::string & | msg | ) |
throw | ( | SocketRecvFailed
| ) |  |

private

Definition at line 93 of file HttpConnection.cpp.

{
try
{
return m_parser.readHttpMessage( msg );
}
catch ( MessageParseError& )
{
disconnect( 400 );
}
return true;
}

Referenced by processStream().

## send()

bool FIX::HttpConnection::send | ( | const std::string & | msg | ) |

private

Definition at line 43 of file HttpConnection.cpp.

{
return socket_send( m_socket, msg.c_str(), msg.length() ) >= 0;
}

References m_socket, and FIX::socket_send().

Referenced by disconnect(), and processRequest().

## showRow() [1/3]

void FIX::HttpConnection::showRow | ( | std::stringstream & | s,
|  | const std::string & | name,
|  | bool | value,
|  | const std::string & | url = `""`
| ) |  |

private

Definition at line 675 of file HttpConnection.cpp.

{
{ TR tr(s); tr.text();
{ TD td(s); td.text(name); }
{ TD td(s); td.text(value ? "yes" : "no"); }
{ TD td(s); td.text();
CENTER center(s); center.text();
if( url.size() )
{
std::stringstream href;
href << url << "&" << name << "=" << !value;
A a(s); a.href(href.str()).text("toggle");
}
}
}
}

References HTML::A::href(), and HTML::TAG::text().

## showRow() [2/3]

void FIX::HttpConnection::showRow | ( | std::stringstream & | s,
|  | const std::string & | name,
|  | const std::string & | value,
|  | const std::string & | url = `""`
| ) |  |

private

Definition at line 693 of file HttpConnection.cpp.

{
{ TR tr(s); tr.text();
{ TD td(s); td.text(name); }
{ TD td(s); td.text(value); }
{ TD td(s); td.text();
CENTER center(s); center.text();
}
}
}

References HTML::TAG::text().

## showRow() [3/3]

void FIX::HttpConnection::showRow | ( | std::stringstream & | s,
|  | const std::string & | name,
|  | int | value,
|  | const std::string & | url = `""`
| ) |  |

private

Definition at line 705 of file HttpConnection.cpp.

{
{ TR tr(s); tr.text();
{ TD td(s); td.text(name); }
{ TD td(s); td.text(value); }
{ TD td(s); td.text();
CENTER center(s); center.text();
{
std::stringstream href;
href << url << "&" << name << "=" << value - 10;
A a(s); a.href(href.str()).text("<<");
}
s << NBSP;
{
std::stringstream href;
href << url << "&" << name << "=" << value - 1;
A a(s); a.href(href.str()).text("<");
}
s << NBSP << "|" << NBSP;
{
std::stringstream href;
href << url << "&" << name << "=" << value + 1;
A a(s); a.href(href.str()).text(">");
}
s << NBSP;
{
std::stringstream href;
href << url << "&" << name << "=" << value + 10;
A a(s); a.href(href.str()).text(">>");
}
}
}
}

References HTML::A::href(), HTML::NBSP, and HTML::TAG::text().

## showToggle()

void FIX::HttpConnection::showToggle | ( | std::stringstream & | s,
|  | const std::string & | name,
|  | bool | value,
|  | const std::string & | url
| ) |  |

private

## Member Data Documentation

## m_buffer

char FIX::HttpConnection::m_buffer[BUFSIZ]

private

Definition at line 88 of file HttpConnection.h.

Referenced by read().

## m_fds

fd_set FIX::HttpConnection::m_fds

private

Definition at line 91 of file HttpConnection.h.

Referenced by HttpConnection(), and read().

## m_parser

HttpParser FIX::HttpConnection::m_parser

private

Definition at line 90 of file HttpConnection.h.

Referenced by read().

## m_socket

int FIX::HttpConnection::m_socket

private

Definition at line 87 of file HttpConnection.h.

Referenced by disconnect(), HttpConnection(), read(), and send().

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

- HttpConnection.h
- HttpConnection.cpp

HTML::TR
Definition: HtmlBuilder.h:195
FIX::RESET_ON_LOGOUT
const char RESET_ON_LOGOUT[]
Definition: SessionSettings.h:143
FIX::RESET_ON_LOGON
const char RESET_ON_LOGON[]
Definition: SessionSettings.h:142
FIX::LOGOUT_TIMEOUT
const char LOGOUT_TIMEOUT[]
Definition: SessionSettings.h:96
FIX::LOGON_TIMEOUT
const char LOGON_TIMEOUT[]
Definition: SessionSettings.h:95
FIX::HttpConnection::processRefreshSessions
void processRefreshSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:281
FIX::Session::lookupSession
static Session * lookupSession(const SessionID &)
Definition: Session.cpp:1513
HTML::HR
Definition: HtmlBuilder.h:155
FIX::HttpParser::readHttpMessage
bool readHttpMessage(std::string &str)
Definition: HttpParser.cpp:49
FIX::HttpConnection::send
bool send(const std::string &)
Definition: HttpConnection.cpp:43
FIX::HttpMessage::createResponse
static std::string createResponse(int error=0, const std::string &text="")
Definition: HttpMessage.cpp:103
HTML::NBSP
const char * NBSP
Definition: HtmlBuilder.h:162
FIX::PERSIST_MESSAGES
const char PERSIST_MESSAGES[]
Definition: SessionSettings.h:149
HTML::HEAD
Definition: HtmlBuilder.h:148
FIX::HttpConnection::processResetSession
void processResetSession(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:559
FIX::Session::reset
void reset()
Definition: Session.h:100
FIX::Session::refresh
void refresh()
Definition: Session.h:102
HTML::H2
Definition: HtmlBuilder.h:141
FIX::Session::getSessions
static std::set< SessionID > getSessions()
Definition: Session.cpp:1502
FIX::Session::numSessions
static size_t numSessions()
Definition: Session.cpp:1570
FIX::CHECK_LATENCY
const char CHECK_LATENCY[]
Definition: SessionSettings.h:76
FIX::socket_recv
ssize_t socket_recv(int s, char *buf, size_t length)
Definition: Utility.cpp:187
FIX::HttpConnection::processSession
void processSession(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:422
FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition: FieldTypes.h:940
FIX::SEND_REDUNDANT_RESENDREQUESTS
const char SEND_REDUNDANT_RESENDREQUESTS[]
Definition: SessionSettings.h:62
FIX::IntConvertor::convert
static std::string convert(signed_int value)
Definition: FieldConvertors.h:170
FIX::HttpConnection::m_parser
HttpParser m_parser
Definition: HttpConnection.h:90
HTML::H1
Definition: HtmlBuilder.h:134
FIX::HttpConnection::showRow
void showRow(std::stringstream &s, const std::string &name, bool value, const std::string &url="")
Definition: HttpConnection.cpp:675
FIX::MAX_LATENCY
const char MAX_LATENCY[]
Definition: SessionSettings.h:77
FIX::HttpConnection::processEnableSessions
void processEnableSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:328
FIX::MILLISECONDS_IN_TIMESTAMP
const char MILLISECONDS_IN_TIMESTAMP[]
Definition: SessionSettings.h:146
FIX::HttpConnection::processStream
void processStream()
Definition: HttpConnection.cpp:107
FIX::socket_send
ssize_t socket_send(int s, const char *msg, size_t length)
Definition: Utility.cpp:192
FIX::HttpConnection::processRefreshSession
void processRefreshSession(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:617
HTML::CENTER
Definition: HtmlBuilder.h:120
FIX::HttpConnection::processDisableSessions
void processDisableSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:375
FIX::HttpConnection::processResetSessions
void processResetSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:234
FIX::HttpConnection::m_buffer
char m_buffer[BUFSIZ]
Definition: HttpConnection.h:88
HTML::EM
Definition: HtmlBuilder.h:127
HTML::TD
Definition: HtmlBuilder.h:178
HTML::BODY
Definition: HtmlBuilder.h:99
FIX::HttpConnection::m_socket
int m_socket
Definition: HttpConnection.h:87
FIX::CHECK_COMPID
const char CHECK_COMPID[]
Definition: SessionSettings.h:75
FIX::HttpConnection::readMessage
bool readMessage(std::string &msg)
Definition: HttpConnection.cpp:93
FIX::REFRESH_ON_LOGON
const char REFRESH_ON_LOGON[]
Definition: SessionSettings.h:145
FIX::socket_close
void socket_close(int s)
Definition: Utility.cpp:197
FIX::RESET_ON_DISCONNECT
const char RESET_ON_DISCONNECT[]
Definition: SessionSettings.h:144
FIX::Session::logon
void logon()
Definition: Session.h:89
HTML::CAPTION
Definition: HtmlBuilder.h:113
FIX::HttpConnection::processRoot
void processRoot(const HttpMessage &, std::stringstream &h, std::stringstream &b)
Definition: HttpConnection.cpp:182
FIX::HttpConnection::processRequest
void processRequest(const HttpMessage &)
Definition: HttpConnection.cpp:126
FIX::Session::logout
void logout(const std::string &reason="")
Definition: Session.h:91
FIX::HttpConnection::disconnect
void disconnect(int error=0)
Definition: HttpConnection.cpp:48
HTML::TITLE
Definition: HtmlBuilder.h:188
HTML::A
Definition: HtmlBuilder.h:89
FIX::HttpConnection::m_fds
fd_set m_fds
Definition: HttpConnection.h:91
FIX::HttpParser::addToStream
void addToStream(const char *str, size_t len)
Definition: HttpParser.h:79
HTML::TABLE
Definition: HtmlBuilder.h:164