diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-10-28 16:18:46 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-11-01 15:30:18 +0000 |
commit | 9857efc0c58422c7cdbe5ad807eed77462808730 (patch) | |
tree | e88b56562ca79298187ce6d0c0f39ca7ce0d38b3 /examples | |
parent | e4caafbd47b9a2f2e98461e052827f73a7be25d6 (diff) |
planets-qml: write proper HTTP responses in command server
This allows to see in a web browser that a command succeeded,
for example, rather than reporting that the server dropped the
connection.
Change-Id: Ib6d34f8261112dd8c76d13dece542a6da229de03
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qt3d/planets-qml/networkcontroller.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/qt3d/planets-qml/networkcontroller.cpp b/examples/qt3d/planets-qml/networkcontroller.cpp index a08a26300..411505a41 100644 --- a/examples/qt3d/planets-qml/networkcontroller.cpp +++ b/examples/qt3d/planets-qml/networkcontroller.cpp @@ -94,12 +94,18 @@ void NetworkController::readyRead() QByteArray reply; if (list.count() == 3) { - reply = "Command accepted."; + socket->write("HTTP/1.1 200 OK\r\n"); + reply = QStringLiteral("Command accepted: %1 %2").arg(list[1], list[2]).toUtf8(); emit commandAccepted(list[1], list[2]); } else { - reply = "Command rejected."; + socket->write("HTTP/1.1 404 Not Found\r\n"); + reply = "Command rejected"; } + socket->write("Content-Type: text/plain\r\n"); + socket->write(QStringLiteral("Content-Length: %1\r\n").arg(reply.size()).toUtf8()); + socket->write("Connection: close\r\n"); + socket->write("\r\n"); socket->write(reply); socket->disconnectFromHost(); } |