GithubHelp home page GithubHelp logo

Comments (4)

hgoebl avatar hgoebl commented on August 15, 2024

This is a good question and for large JSON structures a good decision not to serialize in memory.

But unfortunately I'm not yet familiar with Gson. The only example I can give you is from the test cases. I'd highly apreciate if you find a solution for Gson and tell us how it works.

As I don't want to add heavy dependencies to DavidWebb, there could be a way to extend it more or less like this (pseudo-code):

interface StreamRunnable {
    void doTheStreaming(OutputStream outputStream);
}

Then one could give an object implementing this interface as the body to DavidWebb and it calls the streaming method at the time it processes the body.

from davidwebb.

iberodev avatar iberodev commented on August 15, 2024

Thank you for your reply hgoebl. The test case is very helpful.

I'm new to GSON as well but it basically allows easily serializing an object into JSON as a stream, which allows the HttpURLConnection to start sending chunks of data as chunked Transfer Encode (without knowing the content length) as soon as each serialized token is available and take advantage of low memory-usage in the client. At least that's what I understood, so it would be great to have DavidWebb wrapper being able to send requests with chunked transfer encoding mechanism.

I think that way of extending it would be very good, but somehow DavidWebb would have to add the Transfer Encoding Http header instead the Content-Length if I'm not mistaken (apart from the Content-Encoding to optimize even more the chunks transfer).

from davidwebb.

hgoebl avatar hgoebl commented on August 15, 2024

DavidWebb should already set the header apropriately (when it's not able to find out the content length in advance), have a look at this.

If you find a way to tweak Gson so it's possible to use it without a change of DavidWebb, I'd be glad.
If not, I'll try to find a workaround like mentioned above. Should not be too hard, but currently I'm very busy, so it could take some time.

from davidwebb.

iberodev avatar iberodev commented on August 15, 2024

Thanks again. It's great that it already deals with the headers from its content length. I'll play around with it and see if I can find a way. I'd let you know if I'm successfull.

from davidwebb.

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.