whatwg/xhr

Expanding the XHR interface to mirror expansions to the fetch interface?

davidvancleve opened this issue · 9 comments

My understanding is that it's generally discouraged to add flashy new features to XHR. (I don't have a ton of domain expertise, so please let me know if this premise is wrong.)

I have a question about a special case. If a new Web Platform feature is primarily an extension to Fetch (for instance, defining an addtion to the interface and some corresponding new request handling logic), does it seem like it might be reasonable to mirror the fetch API changes (e.g. expanding RequestInit) with corresponding XHR changes? The motivation would be that there are some people who, for whatever reason, can't use the fetch API but can use XHR; this would allow them to make use of the new Fetch-first Web Platform feature.

(The specific example I have in mind is the Trust Token API, which expands RequestInit to take a new argument specifying a cryptographic operation to execute alongside the request; in its prototype implementation in Chromium, we add a corresponding new setter to XMLHttpRequest so clients can access the same functionality via XHR. @jeremyroman, who was reviewing my XHR change, suggested I drop by and ask whether there are any issues with this approach.)

No, we don't want to extend XMLHttpRequest with new features, except if it gets them through a shared primitive, but that would not be the case here. Also, could you please file an issue against whatwg/fetch with the proposed extension? (See https://annevankesteren.nl/2014/02/monkey-patch for context.)

At the risk of straying off the topic of this issue, I don't understand what you'd like the whatwg/fetch issue to describe. Would it just be a high level "we have a prototype implementation including an extension to the interface and implicit extensions to some of the spec's algorithms and hope to, at some point, codify this new functionality by extending the spec" kind of comment?

Yeah and maybe explicitly solicit feedback from the community on the approach taken.

Can this be closed or is this still being considered?

E.g., say that we started supporting fetching of blah: URLs. XMLHttpRequest would not go out of its way to exclude that. (On the other hand, we have excluded ReadableStream object support from XMLHttpRequest despite it initially supporting that: #277.)

Got it! Thanks.