Giter Site home page Giter Site logo

Comments (8)

mlynch avatar mlynch commented on June 22, 2024

Good catch, looking into it

from http.

mlynch avatar mlynch commented on June 22, 2024

Hmm just tested this with a gzip response and it works fine for me. The docs for HTTPURLConnection even say this automatically handles gzip:

image

Any other specifics about your setup that might be causing this to fail?

from http.

d4mn avatar d4mn commented on June 22, 2024

Hm i wasn't sure also about that when I read docs and what other users talk in the stackoverfow and when I added this fix the data had been decoded correctly. I need more tests to do this. One thing I also changed is my "Accept-Encoding" header changed from "gzip, br, deflate" to "gzip" could be that multiple accept parameters caused this bug. I will try to test it as soon as I can reach my code and will let you know!

from http.

mlynch avatar mlynch commented on June 22, 2024

Will test this with custom headers, maybe they are overwriting somehow

from http.

d4mn avatar d4mn commented on June 22, 2024

Hi, i tested it with multiple headers and when you put headers: {"Accept-Encoding": "gzip"} in the headers list and server is configured to return gzip compressed response then the lib doesn't decode data automatically. You have to decode stream your self. The problem disappears if you remove this header and server doesn't compress data. It's kind of not like a bug but more like a feature if user explicitly wants compressed data for example if returned data is a very big json response then yes compressing and decompressing is needed otherwise you can just scrip this header and you're good to go. Thanx for looking into this!

P.S IF it's not hard you can put simple check for this that other users don't get lost about it. It does nothing harm. Here is what i used: in buildResponse function
InputStream stream = (errorStream != null ? errorStream : conn.getInputStream()); String encoding = conn.getContentEncoding(); if (encoding != null && encoding.contains("gzip")) { stream = new GZIPInputStream(stream); } BufferedReader in = new BufferedReader(new InputStreamReader(stream));

from http.

mlynch avatar mlynch commented on June 22, 2024

Thanks! Just so I understand, if you remove this header and the server does compress the data, it works for you, yes?

Because that worked fine for me.

from http.

d4mn avatar d4mn commented on June 22, 2024

If your remove this header server won't compress the data that's how nginx or apache works. Unless some custom addon used or something. Data is compressed only then when asked.

from http.

thomasvidas avatar thomasvidas commented on June 22, 2024

BuildResponse now does catch IOException 😄. Closing this as the issue appears to be fixed in the capacitor-v3 branch

from http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.