QNetworkReply does not get any headers
-
I'm coding an app to get information of a device on which I have to send a PUT request like this
@ QByteArray data("0ABF0A25");
QNetworkReply req(QUrl("192.168.1.100"));
req.setHeader(QNetworkRequest::ContentLengthHeader,data.length());
netman.put(req,data);@I know the device is working because starts its process and I put a sniffer between my PC and the device and I see the response
485454502F312E3020323030204F4B200D0A
or in plain text 'HTTP/1.0 200 OK \r\n'but on when slotRequestFinished(QNetworkReply* rep) slot is executed I get no data, no headers and no attributes, and error code 2 (connection closed)
If i execute@ QVariant attr = rep->attribute(QNetworkRequest::HttpStatusCodeAttribute);@
I get and invalid variant object, same for the headers.
How can I get the raw packets of the response? that would be handy for this case
I also noticed on my sniffer that the connection repeats three times, and sends the request all these times.
Could that be an issue with the library? -
Great question!
I have a similar problem with QWebView when making an https connection. After some work I was able to bypass QWebView and reproduce the problem by using only QNetWorkAccessManager. The problem seemed to occur intermittently but I found that trying to connect to the URL "https://login.comcast.net/" consistly failed. After using QDebug to print out responses I found just like you that the symptom is no response even though something is being sent (note the test url works on all the major browsers).
Sorry this isn't much help and I haven't had time to pursue this further but perhaps knowing that the above url reproduces the problem will help someone to solve it. I am very interested in learning if it becomes resolved.
-
I'm thinking that the problem is that the host close the connection prematurely, not giving enough time to QNetWorkAccessManager and/or QNetworkReply to properly set all the attributes and headers received.
But is just guessing.
I've started to look at their code.