GithubHelp home page GithubHelp logo

Comments (4)

tomas avatar tomas commented on July 19, 2024

You're welcome. To stop at a specific point (e.g. after 10000 bytes have been transferred) you'd need to count the chunk lengths and stop the stream whenever over that limit. Usually I have no problem implementing stuff on Needle as requested, but in this case it looks like a really specific use case.

What are you trying to do, if I may ask?

from needle.

bitinn avatar bitinn commented on July 19, 2024

Thx for the response, I am just trying to limit download size for potential memory issue.

Say I have a open system that allow user submit url so we fetch content of that link. Then potentially one could construct a large json file and make an attempt to fetch it, which probably will crash the worker instance due to memory issue. Using stream we can effectively avoid such problem.

Though I was wrong at assuming decoder required buffering to work with chunk, it would seem that only parser require buffering. So this might not be an issue after all, I will give it a go first and report back.

from needle.

bitinn avatar bitinn commented on July 19, 2024

@tomas things are working fine, just 1 question, is stream.request.abort() is right way to close a on-going needle request when my limit is reached?

from needle.

tomas avatar tomas commented on July 19, 2024

As far as I know, yup, that should do it.

from needle.

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.