Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifying Accept-Encoding breaks content decoding #20

Open
rmallah opened this issue Sep 16, 2018 · 2 comments
Open

specifying Accept-Encoding breaks content decoding #20

rmallah opened this issue Sep 16, 2018 · 2 comments

Comments

@rmallah
Copy link

rmallah commented Sep 16, 2018

Hi ,

If one of the tests is modified as below it
fails.

diff --git a/tests/tst_duperagent.qml b/tests/tst_duperagent.qml
index 38f2eff..8da30be 100644
--- a/tests/tst_duperagent.qml
+++ b/tests/tst_duperagent.qml
@@ -135,6 +135,7 @@ TestCase {
     function test_gzip() {
         Http.Request
             .get("http://httpbin.org/gzip")
+           .set('Accept-Encoding', 'gzip, deflate')
             .end(function(err, res){
                 verify(!err, err);
                 compare(res.status, 200);


============================================
function test_gzip() {
        Http.Request
            .get("http://httpbin.org/gzip")
            .set('Accept-Encoding', 'gzip, deflate')
            .end(function(err, res){
                verify(!err, err);
                compare(res.status, 200);
                compare(res.body.gzipped, true);
                done();
            });

        async.wait(timeout);
    }
===========================================

@rmallah
Copy link
Author

rmallah commented Sep 16, 2018

I tried to peek at the ByteArray , the data returned by QIODevice::readAll()
in case accept-encoding is sent , the data indeed begins with the magic
number of 0x1f8b , that indicated gzipped stream.

can we simply inflate the stream if this magic numbers are present in the begin
of stream ?

response.cpp

 if (m_reply->isReadable()) {
        QByteArray data = m_reply->readAll();

        qDebug() << " data is: " << data;

QDEBUG : duperagent::httpbin::test_gzip() data is: "\x1F\x8B\b\x00x{\x9E[\x02\xFF""E\x90\xC1N\xC3""0\x10""D\xEF\xF9\n\xCBG\x94\x18""B\x05TT9TU\x05H\xC0\t>\xC0\xB5""7\xCE\x8A\xE0\xB5\xEC\xED\x81T\xFDw\xECTJo\xBB""3\xF3\xA4\xD9=UBH7a\b`\xE5\xB3\xE0x\x84Z\x14m\x00m!\xA6\xAC\x9D\xF2\x9A\x85\xAD""1\x10\xB8\xD9{C\x16\xBD\xCB\xC6\xCC\xD5\xC2""B?j\x06""9s\xD7\xE0\xBB\xF6\xEE\xA8\x1D\x94 \xF8\xE6\xED\xB3\xBEY\";\xF2\x1E\f#\xF9\xE2\x9A\x91\xD2\x15\xDF\x11\xFD\xE0L\xF5""D\xDD""A\xC7\x8D\xC8\x83\xED\x02N\x93\xDE\x88\x90Kab\xF0\xDC\xF5\x14\xDB?\xD0qA_)q\x01\x07\xE6p@\xAF(\xBA\xC5\xFBN\x10\x9B\xAD\xCB\\I|\xD0\x84\xE3\xA8o\x1F\xD4\x9D\xCC\xFE\xF9r\xF3/\xF0@\xE5\r\xF2""e\xFFu!%Et8\xD7l\xD7\xF7\xEAq\xADV+\xD5>\xB5\xB2:W\xFF/C\xCF\x14<\x01\x00\x00"

@rmallah
Copy link
Author

rmallah commented Jun 9, 2019

The originally reported issue is still an issue. This has been re-verified on linux as well as macOS host
with latest master branch . I finally removed 'Accept-Encoding' from my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant