#include <sstream>
{
std::cout <<
"--- " << req.
method <<
" " << req.
target << std::endl;
{
return;
}
std::ostringstream os;
os << "{"
<<
"\"method\":\"" << req.
method <<
"\","
<<
"\"target\":\"" << req.
target <<
"\","
<<
"\"client-proto-major\":" << req.
ver_major <<
","
<<
"\"client-proto-minor\":" << req.
ver_minor <<
","
<< "\"headers\":{";
Async::HttpServerConnection::Headers::const_iterator it;
{
std::cout << (*it).first << ": " << (*it).second << std::endl;
{
os << ",";
}
os << "\"" << (*it).first << "\":\"" << (*it).second << "\"";
}
os << "}}";
{
}
}
{
std::cout << "/// Client connected: "
}
{
std::cout << "\\\\\\ Client disconnected: "
<< std::endl;
}
int main(void)
{
server.clientConnected.connect(sigc::ptr_fun(&clientConnected));
server.clientDisconnected.connect(sigc::ptr_fun(&clientDisconnected));
}
The core class for writing asyncronous cpp applications.
A simple HTTP Server connection class.
A class for creating a TCP server.
An application class for writing non GUI applications.
void quit(void)
Exit the application main loop.
void catchUnixSignal(int signum)
Catch the specified UNIX signal.
void exec(void)
Execute the application main loop.
sigc::signal< void, int > unixSignalCaught
A signal that is emitted when a monitored UNIX signal is caught.
void setCode(unsigned code)
void setContent(const std::string &content_type, const std::string &content)
void setSendContent(bool send_content)
A class representing a HTTP server side connection.
sigc::signal< void, HttpServerConnection *, Request & > requestReceived
A signal that is emitted when a HTTP request has been received on the connection.
virtual bool write(const Response &res)
Send a HTTP response.
static const char * disconnectReasonStr(DisconnectReason reason)
Translate disconnect reason to a string.
const IpAddress & remoteHost(void) const
Return the IP-address of the remote host.
uint16_t remotePort(void) const
Return the remote port used.
DisconnectReason
Reason code for disconnects.
A class for creating a TCP server.