views:

134

answers:

3

I am using QNetworkManager to fetch files from a server, however what I cannot figure out is if the files are compressed during the transfer with the standard gzip compression and if not how to get them to download compressed.

How would I go about checking?

A: 

You should use a packet sniffer / network analyzer and check for yourself.

QNetworkAccessManager does support receiving compressed HTTP replies, so in theory it should work if the HTTP server is correctly set up.

guruz
A: 

Hey,

Considering the following sentence, I would say no, but they can be :

The downloadProgress() signal is also emitted when data is received, but the number of bytes contained in it may not represent the actual bytes received, if any transformation is done to the contents (for example, decompressing and removing the protocol overhead).

You can find it here : http://doc.trolltech.com/4.6/qnetworkreply.html

I didn't test it tho !

To compress, if I remember well, you can send QByteArray... And on this kind of objects, you can use "compress"...

You could also have a look at some Qt examples, like :

http://doc.trolltech.com/4.6/network-broadcastsender.html

I didn't look at all of them but maybe you'll find some interesting things !

Hope it helps a bit !

Andy M
A: 

I just ran a quick test by adding:

request.setRawHeader("Accept-Encoding", "gzip,deflate");

to the QNetworkRequest and the data returns what look compressed (because its ~20% smaller and unusable).

It appears that the QNetworkManager and the QNetworkReply are not intelligent as far as decompression is concerned. It looks like I have to implement a gzip and/or deflate on the returned QByteArray.

Phil Hannent