mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-24 22:19:33 -04:00
Fully functional http plugin with qhttp
This commit is contained in:
parent
86f2c9d350
commit
e9e92d0892
1 changed files with 5 additions and 1 deletions
|
@ -178,7 +178,8 @@ void Server::handleRequest(const QByteArray& data, QHttpResponse* response)
|
||||||
}
|
}
|
||||||
|
|
||||||
response->setStatusCode(qhttp::ESTATUS_OK);
|
response->setStatusCode(qhttp::ESTATUS_OK);
|
||||||
response->write(out.toUtf8());
|
response->addHeader("Content-Type", "application/json");
|
||||||
|
response->end(out.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::start(void)
|
void Server::start(void)
|
||||||
|
@ -194,6 +195,8 @@ void Server::start(void)
|
||||||
m_server = new QHttpServer(this);
|
m_server = new QHttpServer(this);
|
||||||
m_server->listen(address, port);
|
m_server->listen(address, port);
|
||||||
connect(m_server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)), this, SLOT(onNewRequest(QHttpRequest*, QHttpResponse*)));
|
connect(m_server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)), this, SLOT(onNewRequest(QHttpRequest*, QHttpResponse*)));
|
||||||
|
|
||||||
|
m_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::stop(void)
|
void Server::stop(void)
|
||||||
|
@ -211,6 +214,7 @@ void Server::onNewRequest(QHttpRequest* request, QHttpResponse* response)
|
||||||
if (!isDatabaseOpened()) {
|
if (!isDatabaseOpened()) {
|
||||||
if (!openDatabase()) {
|
if (!openDatabase()) {
|
||||||
response->setStatusCode(qhttp::ESTATUS_SERVICE_UNAVAILABLE);
|
response->setStatusCode(qhttp::ESTATUS_SERVICE_UNAVAILABLE);
|
||||||
|
response->end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue