Giter Site home page Giter Site logo

Comments (18)

wheresrhys avatar wheresrhys commented on September 25, 2024

I'll write a failing test and then look at this. It's not a feature I've explored much

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

I've added a test #95 which passes in node 5. I notice you have sendAsJSON in your code when it should be sendAsJson. I've managed to get it to pass in node 5 and 6

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

Good point regarding the key name, but this issue is about ArrayBuffer, not Buffer.

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

Ah, and it turns out I wrote the issue incorrectly - the actual code I wrote uses sendAsJson.

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

I suggest raising this as an issue on node-fetch, which this library uses to construct responses. It already supports use cases that go beyond the fetch spec, so they could be keen to add support for ArrayBuffer

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

What does this have to do with the fetch spec? The fetch spec already supports ArrayBuffer on the response https://developer.mozilla.org/en-US/docs/Web/API/Body/arrayBuffer

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

I assumed you were running the tests in node (as opposed to in a browser) as the error stack looks more like something generated in node. If this is the case then support for arrayBuffer needs to be added to node-fetch. node-fetch/node-fetch#51. Not everything defined in the fetch spec is implemented, or is even intended to be implemented (https://github.com/bitinn/node-fetch/blob/master/LIMITS.md), in node-fetch, but for most use cases it's similar enough.

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

What does this have to do with node-fetch? The error stack is entirely within fetch-mock.

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

Ah I missed that sorry. I now have a failing test and will work on fixing it

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

Great! Any luck?

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

I have a failing test, but I'm still looking into what the behaviour should be with regard to building a Body from binary data. The spec https://fetch.spec.whatwg.org/#bodies mentions that ReadableStream may change to be ReadableByteStream, which may have some bearing on it.

Other than that I need to update fetch-mock to use stream.pipe() and add a check body isn't an ArrayBuffer before trying to 'utf8' decode, which may be enough

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

This might become a ReadableByteStream object. While the type might change, the behavior specified will be equivalent since the hypothetical ReadableByteStream object will have the same members as the ReadableStream object has today.

What bearing would that have on the behaviour? Can you share your failing test? I'd like to help you get this over the finish.

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

here you go https://github.com/wheresrhys/fetch-mock/compare/rhys/buffer

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

FWIW it seems that this mostly works in the browser already (as opposed to NodeJS), but there's still some weirdness in webkit as seen in https://github.com/cockroachdb/cockroach/pull/7178/files - still not quite sure what's going on there.

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

closing due to incativity

from fetch-mock.

tamird avatar tamird commented on September 25, 2024

Sorry, this was JakeChampion/fetch#351.

from fetch-mock.

qjflores avatar qjflores commented on September 25, 2024

was this implemented update fetch-mock to use stream.pipe()?

from fetch-mock.

wheresrhys avatar wheresrhys commented on September 25, 2024

@qjflores Please open a new issue if something is missing for you. I have very little memory of what this discussion was about

from fetch-mock.

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.