这是一个简单的Qt C ++ HTTP服务器。
当我尝试发送帖子请求时,我看到下一个输出
“ POST /?test = 23&someKey = 42 HTTP / 1.1”
如何将其转换为json?
tcpServer = new QTcpServer();
if (!tcpServer->listen(QHostAddress::Any, 2323)) {
qDebug() << "ERROR: " << tcpServer->errorString();
return;
}
qDebug() << "Ip: " << tcpServer->serverAddress();
qDebug() << "Port: " << tcpServer->serverPort();
QObject::connect(tcpServer, &QTcpServer::newConnection, [=]() {
QTcpSocket *clientSocket = tcpServer->nextPendingConnection();
QObject::connect(clientSocket, &QTcpSocket::readyRead, [=]() {
qDebug() << clientSocket->readLine();
});
});