Giter Site home page Giter Site logo

Comments (4)

redraushan avatar redraushan commented on April 29, 2024 1

@kettanaito this was the issue that I discussed with you, itโ€™s my bad I literally forgot to implement the changes. If anyone is not taking in 2-3 days, itโ€™s mine ๐Ÿ˜…

from msw.

hehehai avatar hehehai commented on April 29, 2024 1

@kettanaito I'm sorry, I don't have any ideas at the moment๐Ÿ˜

from msw.

kettanaito avatar kettanaito commented on April 29, 2024

Noting down our productive discussion with @redraushan below.

Data structure

I suggest to store the multiple headers in a list of tuples:

// mockServiceWorker.js
// This would need to be constructed dynamically from "req.headers"
const headers = [['name', 'value'], ['name', 'value']]

Current implementation mirrors the req.headers into a new object instance:

https://github.com/open-draft/msw/blob/6b4242845bb6d301252fbd41c0f4818ce4883e5b/mockServiceWorker.js#L62-L65

De-serialization

When accepted from the MSW on the client side in interceptRequest(), the custom reviver function during JSON parsing should be adjusted to handle the list of tuples. Now it passes the object to new Headers() right away.

https://github.com/open-draft/msw/blob/6b4242845bb6d301252fbd41c0f4818ce4883e5b/src/utils/interceptRequest.ts#L15-L17

from msw.

kettanaito avatar kettanaito commented on April 29, 2024

I was going through the open issues and this is one of the most needed things at the moment. I was wondering if you have the time/desire to implement this, @hehehai? Feel free to say no, I'd try to do this some time next week in that case.

from msw.

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.