cnm
cnm

Reputation: 113

QNetworkAccessManager->get without VPN returns "Connection closed" from the server

I have the following two code snips. The first code snip works fine for the environment with and without VPN. The second code snip only works fine for the environment with VPN, and it returns "Connection closed" without VPN. All the values that are assigned to the parameters are the same.

First code snip:

var http = new XMLHttpRequest()
query = "https://......"
http.open("get", query)
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
http.setRequestHeader("X-API-KEY", "xxxxx")
http.setRequestHeader("Cache-Control", "no-cache")
http.setRequestHeader("Ocp-Apim-Subscription-Key", "xxxxx")
http.send();

second code snip:

m_netManager = new QNetworkAccessManager(this);
QUrl url = "https://......";
QNetworkRequest request = QNetworkRequest(url);
QByteArray baKey = QByteArray(m_apiKey.toLatin1());
request.setRawHeader("Ocp-Apim-Subscription-Key", baKey);
request.setRawHeader("X-API-KEY", baKey);
request.setRawHeader("Cache-Control", "no-cache");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
m_serialNumberReply = m_netManager->get(request);

Upvotes: 0

Views: 34

Answers (0)

Related Questions