34 if (m_server != NULL) {
41 QHostAddress address = m_settings->address();
42 int port = m_settings->port();
44 if (m_server != NULL) {
49 connect(m_server, SIGNAL( newConnection()),
52 m_server->listen(address, port);
54 if (!m_server->isListening()) {
55 qWarning(
"HttpServer cannot bind on %s:%i : %s",
56 qPrintable(address.toString()),
58 qPrintable(m_server->errorString())
77 bool threads = m_settings->threads();
78 while (m_server->hasPendingConnections()) {
79 QTcpSocket *socket = m_server->nextPendingConnection();
80 QPointer<HttpConnection> connection =
new HttpConnection(
this, socket);
81 socket->setParent(connection);
82 connection->setPeerCertificate(m_server->peerCertificate(socket));
83 connection->setVerified(m_server->verified(socket));
86 QThread *thread =
new QThread(
this);
87 thread->setObjectName(
"Http connection");
89 m_connections << connection;
90 connection->setParent(0);
91 connection->moveToThread(thread);
92 connect(connection, SIGNAL(destroyed(QObject *)),
93 this, SLOT(slotConnectionClosed(QObject *)));
94 connect(connection, SIGNAL(destroyed(QObject *)),
95 thread, SLOT(quit()));
96 connect(thread, SIGNAL(finished()),
97 thread, SLOT(deleteLater()));
103 void HttpServer::slotConnectionClosed(QObject *
object) {
108 m_connections.removeAll(NULL);
112 QVariant HttpServer::webStatus()
const {
113 QVariantList objectlist;
114 QObjectList list = children();
115 for (
int i=0; i<list.size(); i++) {
116 const QObject *qobject = list[i];
117 QString classname = qobject->metaObject()->className();
118 if (classname !=
"HobrasoftHttpd::HttpConnection") {
122 objectlist += connection->webStatus().toList();
const HttpSettings * settings() const
Returs pointer to HttpSettings used in the HttpServer.
void slotNewConnection()
Slot is invoked when QTcpServer::newConnection() signal arrived.
Listens for incoming TCP connections, supports plain and ssl connections.
HttpServer(QObject *parent)
Constructor using default HttpSettings object.
Configuration of the http server instance.
void close()
Closes the QTcpServer bind with your HttpServer.
Processes incoming requests.
virtual HttpRequestHandler * requestHandler(HttpConnection *)
Creates new request handler and returs pointer to it.
void start()
Starts of restart HttpServer with new parameters.
Namespace of HTTP server.
One single connection to http server.