I'm trying to send a HTTP POST login request in the following format:
POST /login HTTP/1.1
Content-Type: text/xml
Content-Length: 450
Host: 123.456.78.91:80
KeepAlive-Interval: 5
[CONTENT (contains security key)]
Currently, my code is structured like:
qUrl->setHost(ipAddress);
qUrl->setPort(port);
qUrl->setPath("/login");
request = QNetworkRequest(qUrl)
request.
setRawHeader("Content-Length",
QString::number(securityKey.
size()).
toLocal8Bit);
... more headers ...
QNetworkAccessManager* networkManager = new QNetworkAccessManager();
networkManager->connectToHost(ipAddress, port);
networkManager->post(request, content.toLocal8Bit());
qUrl = new QUrl();
qUrl->setHost(ipAddress);
qUrl->setPort(port);
qUrl->setPath("/login");
request = QNetworkRequest(qUrl)
request.setRawHeader("Content-Length", QString::number(securityKey.size()).toLocal8Bit);
... more headers ...
QString content = "contents..."
QNetworkAccessManager* networkManager = new QNetworkAccessManager();
networkManager->connectToHost(ipAddress, port);
networkManager->post(request, content.toLocal8Bit());
To copy to clipboard, switch view to plain text mode
Currently I'm not receiving any response from the server so something's wrong. I'm wondering if anyone is able to identify what it may be? I haven't seen any examples online of people connecting to ip addresses/ports with Qt networking so I'm not sure if what I'm doing is correct.
Any help would be much appreciated!
Bookmarks