#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;
}
{
std::cout << "/// SSL Client connected: "
}
{
std::cout << "\\\\\\ SSL Client disconnected: "
<< std::endl;
}
int main(void)
{
server.clientConnected.connect(sigc::ptr_fun(&clientConnected));
server.clientDisconnected.connect(sigc::ptr_fun(&clientDisconnected));
ssl_server.setSslContext(ctx);
ssl_server.clientConnected.connect(sigc::ptr_fun(&sslClientConnected));
ssl_server.clientDisconnected.connect(sigc::ptr_fun(&sslClientDisconnected));
}
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.
SSL context meant to be used with TcpConnection and friends.
bool setCertificateFiles(const std::string &keyfile, const std::string &crtfile)
Set which key and certificate file to use for connections.
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.
void enableSsl(bool enable)
Enable or disable TLS for this connection.
A class for creating a TCP server.