10 #include <QCoreApplication> 15 : QTcpServer(parent), useQtSettings(true)
17 Q_ASSERT(settings != 0);
18 Q_ASSERT(requestHandler != 0);
23 qRegisterMetaType<tSocketDescriptor>(
"tSocketDescriptor");
31 Q_ASSERT(requestHandler != 0);
37 qRegisterMetaType<tSocketDescriptor>(
"tSocketDescriptor");
46 qDebug(
"HttpListener: destroyed");
62 QTcpServer::listen(host.isEmpty() ? QHostAddress::Any : QHostAddress(host), port);
65 qCritical(
"HttpListener: Cannot bind on port %i: %s",port,qPrintable(errorString()));
68 qDebug(
"HttpListener: Listening on port %i",port);
75 qDebug(
"HttpListener: closed");
84 qDebug(
"HttpListener: New connection");
97 QMetaObject::invokeMethod(freeHandler,
"handleConnection", Qt::QueuedConnection, Q_ARG(
tSocketDescriptor, socketDescriptor));
102 qDebug(
"HttpListener: Too many incoming connections");
103 QTcpSocket* socket=
new QTcpSocket(
this);
104 socket->setSocketDescriptor(socketDescriptor);
105 connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
106 socket->write(
"HTTP/1.1 503 too many connections\r\nConnection: close\r\n\r\nToo many connections\r\n");
107 socket->disconnectFromHost();
void incomingConnection(tSocketDescriptor socketDescriptor)
HttpConnectionHandlerPool * pool
HttpRequestHandler * requestHandler
HttpListener(QSettings *settings, HttpRequestHandler *requestHandler, QObject *parent=NULL)
HttpListenerSettings listenerSettings
HttpConnectionHandler * getConnectionHandler()