[Qt-interest] QHttp getting empty response
Thiago Macieira
thiago at kde.org
Tue Sep 27 17:47:25 CEST 2011
On Tuesday, 27 de September de 2011 10:31:24 Paul Miller wrote:
> I have some QHttp code using Qt 4.7
You should use QNetworkAccessManager, which has been available since 4.4.
> that builds a custom request header
> and then waits for a response from the server. This code has been
> working for years, on Mac, Windows, and Linux.
>
> Recently, we've gotten a fair number of people who are not getting
> anything back in the response -just empty data. They are all on Windows
> 7. We're trying to figure out what else is common among them but I
> wanted to see if anyone had seen anything like this. I'm building the
> header like this:
>
> QHttpRequestHeader header("POST", url.toString());
This use of QUrl is wrong. You should use url.toEncoded() and maybe add
QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment.
> header.setValue("Host", url.host());
> header.setValue("Accept",
> "text/xml,application/xml,application/xhtml+xml,text/html");
> header.setValue("Accept-Charset", "ISO-8859-1,utf-8");
> header.setValue("Accept-Language", "en-us,en");
> header.setValue("Connection", "keep-alive");
> header.setValue("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 6.0)";);
> header.setValue("Content-Type", "application/x-www-form-urlencoded");
>
> The request is hitting the server and we've confirmed the server is
> responding with the proper data.
>
> In the "done" slot I'm reading the response like this:
>
> QByteArray data = http->readAll();
>
> The response data is a simple string though - not actually XML or HTML.
> I'm wondering if certain anti-virus software or something else could be
> looking at the response packets, noticing they are not really XML/HTML,
> and filtering them out.
>
> Any suggestions?
It's possible, since you said the code has been running for years in other
places.
The only suggestion I have is to port to the new infrastructure.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110927/83762973/attachment.bin
More information about the Qt-interest-old
mailing list