Coder Social home page Coder Social logo

Comments (9)

mnot avatar mnot commented on September 2, 2024 1

/me admits to thinking it'd be cool if SW would automatically add itself to the Via header.

from fetch.

jpmedley avatar jpmedley commented on September 2, 2024

That should throw a TypeError.

from fetch.

annevk avatar annevk commented on September 2, 2024

@jpmedley (and also @jakearchibald) should fetch() return a response with an immutable Headers object?

from fetch.

annevk avatar annevk commented on September 2, 2024

The alternative is introducing a new guard (response-cors; for opaque we can reuse immutable). Using immutable everywhere for now seems simplest though. @KenjiBaheux thoughts?

from fetch.

jakearchibald avatar jakearchibald commented on September 2, 2024

Being able to add headers like this is kinda nice, but not essential. If we make them mutable, we should do the same with requests.

self.addEventListener('fetch', function(event) {
  event.request.headers.append('foo', 'bar');
});

Of course, that shouldn't work with 'no-cors' requests, probably other kinds of requests too.

If editing headers on fetchEvent.requests & responses returned by fetch throws now, it's something we can open up later.

from fetch.

annevk avatar annevk commented on September 2, 2024

Yeah, I guess I prefer immutable for now then. Until someone comes up with a complete proposal.

from fetch.

wheresrhys avatar wheresrhys commented on September 2, 2024

Is it too soon to revisit the decision on this? It is already possible to achieve cloned headers for non-opaque requests via long-winded hacks (constructing an init object and body from the response/request). For responses it's easier to do this in a non-performant way - wait for the body before creating a response - than it is to do so using streams. It'd be good to make modifying responses in a performant way easier.

What are the reasons for not supporting mutability on same domain requests/responses? @annevk

from fetch.

annevk avatar annevk commented on September 2, 2024

We could revisit it in a new issue. Stuff we need to be clear about if we allow things like that is what it would mean for caches and such.

from fetch.

wheresrhys avatar wheresrhys commented on September 2, 2024

Ok, I'll create an issue, though others will have to fill in the details on caching etc. as nothing problematic occurs to me

from fetch.

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.