This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26244 - The getter methods on Headers need to be asynchronous
Summary: The getter methods on Headers need to be asynchronous
Status: RESOLVED INVALID
Alias: None
Product: WHATWG
Classification: Unclassified
Component: Fetch (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+fetchspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-30 22:16 UTC by Ehsan Akhgari [:ehsan]
Modified: 2014-07-02 16:08 UTC (History)
3 users (show)

See Also:


Attachments

Description Ehsan Akhgari [:ehsan] 2014-06-30 22:16:37 UTC

    
Comment 1 Ehsan Akhgari [:ehsan] 2014-06-30 22:19:55 UTC
Err, pressed Enter by mistake!

The issue that we're facing in Gecko is that we want to construct a Request object in the child process and hand it off to the SW without going to the parent process.  In order to construct some HTTP headers such as Cookies, we do need to run code in the parent process, which means that we need to do this work before we can create a Request object, which will have unacceptable perf implications for us.  I think we need to make at least get, getAll and has on Headers asynchronous.
Comment 2 Ben Kelly 2014-07-01 00:11:47 UTC
So right now the Headers object is pretty dumb.  It is simply a multi-map that has a type of "request", "response", etc.  It doesn't need to know what underlying request its actually tied to.  This is pretty simple and straightforward.

For example, its easy to reason about how one would take the headers from the original SW request and then create a new request using that same Headers object.  If the Headers we tied behind the scenes to the underlying request, that would seem to make this more complex.

As an alternative, could we make the Headers attachment to Request asynchronous instead.  So replace:

  interface Request {
    readonly attribute Headers headers;
  };

With:

  interface Request {
    Promise<Headers> getHeaders();
  };
Comment 3 Ben Kelly 2014-07-01 00:48:33 UTC
Or if comment 2 is not possible, perhaps allowing append() and set() to take Promises would keep things simple.  Headers would still be a multi-map, but on that can store async values.
Comment 4 Anne 2014-07-01 06:15:40 UTC
Wait, did you read the specification Ehsan? Network-level headers such as cookies are added last-minute. They are not normally in the object. Assuming you're talking about requests.
Comment 5 Anne 2014-07-02 15:37:47 UTC
Yeah, it seems like the cross-compartment concern was not justified since there is no cross-compartment interaction per the specification.
Comment 6 Ehsan Akhgari [:ehsan] 2014-07-02 16:08:25 UTC
Yep, Anne's right!