1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* Copyright (C) 2012 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*
* See COPYING for license information.
*
*/
#include "TestResponder.h"
TestResponder::TestResponder()
{
JsonScgiServer *server = new JsonScgiServer(this);
connect(server, SIGNAL(webRequest(QUrl,JsonScgiServer::Session&,QVariantMap,JsonScgiPeer&)), this, SLOT(webRequest(QUrl,JsonScgiServer::Session&,QVariantMap,JsonScgiPeer&)));
server->listen();
}
void TestResponder::webRequest(const QUrl &url, JsonScgiServer::Session &session, const QVariantMap &request, JsonScgiPeer &peer)
{
qDebug() << "Received request to url" << url;
qDebug() << "Client sent this object" << request;
qDebug() << "The current session expires at" << session.expiration;
qDebug() << "The current session data is" << session.data;
if (url.path().endsWith("notfound")) {
peer.notFound();
return;
}
QVariantMap response;
response.insert("cheese", 3);
response.insert("test", "yeehaw");
peer.sendResponse(response);
}
|