Giter Site home page Giter Site logo

Comments (3)

baywet avatar baywet commented on May 19, 2024

Ah this is probably a shortcoming on my side when I implemented this. The fact that it's a finally means it always runs the drain async.

await DrainAsync(response);

We probably have avenues opportunities here:

  • Clone the stream into a memory stream, and return that memory stream instead. This might lead to higher memory usage.
  • Add a condition in the finally. Consumers might lock the connections if they don't dispose the stream in that case.

Thoughts?

from kiota-http-dotnet.

andrueastman avatar andrueastman commented on May 19, 2024

I believe there are scenarios where the response content may be large and consumers would not want/accept to load the entire stream into memory in some scenarios. On a side note, we should also probably add support for passing the HttpCompletionOption to the httpClient as well.

I think adding a condition for streams should be okay as we already call ReadAsStreamAsync() here for streams so the connection should be released as we have read the response body.

return (ModelType)(await response.Content.ReadAsStreamAsync() as object);

from kiota-http-dotnet.

baywet avatar baywet commented on May 19, 2024

Makes sense, thanks for the input. I'm not sure what would be the impact for the completion options (worried about side effects on the service side). Would one of you be so kind to submit a PR to add the condition to the finally please?

from kiota-http-dotnet.

Related Issues (18)

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.