Skip to content

Allow passing a Request instance to Request constructor - #179

Merged
mislav merged 4 commits into
masterfrom
request-to-request
Jul 31, 2015
Merged

mislav merged 4 commits into
masterfrom
request-to-request

Conversation

@mislav

@mislav mislav commented Jul 19, 2015

Copy link
Copy Markdown
Contributor

I tried to match the spec as closely as possible. This should also make it possible to use fetch(request, options) invocation.

Fixes #177

/cc @dgraham @cesarandreu

@cesarandreu

Copy link
Copy Markdown

Oh awesome! That's was really fast.

@cesarandreu

Copy link
Copy Markdown

I just looked through the spec and comparing it with Chrome Canary they seem to at least behave the same.

mislav added 3 commits July 20, 2015 10:51
The new Request instance becomes essentially a clone of the old Request.
The original Request's body becomes unusable.

https://fetch.spec.whatwg.org/#dom-request
This makes the test error more correct when the `then` block raises an
assertion error. The `catch` block needs to re-raise the same exception,
not swallow it and disguise it like another failure.
@mislav
mislav force-pushed the request-to-request branch from c8ac353 to 86d8ec5 Compare July 20, 2015 17:51
@mislav

mislav commented Jul 20, 2015

Copy link
Copy Markdown
Contributor Author

We got a legitimate failure in Chrome because it doesn't conform to the spec fully: a Request with an already consumed body should throw an exception, and in Chrome it doesn't. @dgraham What do we do in these situations?

@dgraham

dgraham commented Jul 21, 2015

Copy link
Copy Markdown
Contributor

@mislav I usually test the behavior in Firefox as well, to determine if both browsers agree on the implementation. It could be a misreading of the specification or a real Chrome bug.

@mislav

mislav commented Jul 21, 2015

Copy link
Copy Markdown
Contributor Author

It passes in Firefox, as well as my polyfill implementation based on the spec. It's not a super-important feature, thoughโ€” it just throws a TypeError early when the body has already been consumed. It looks like Chrome implementation in general allows bodies to be re-consumed.

@cesarandreu

Copy link
Copy Markdown

Possibly related to the following?
whatwg/fetch#55

@mislav

mislav commented Jul 27, 2015

Copy link
Copy Markdown
Contributor Author

Thanks @cesarandreu.

@dgraham It's a real Chrome bug due to the spec only formalizing this very recently. Should I skip the test in Chrome?

@dgraham

dgraham commented Jul 27, 2015

Copy link
Copy Markdown
Contributor

@mislav That sounds fine. We can re-enable the test after Chrome ships a fix for the bug.

The fetch spec instructs that Request should throw a TypeError when
given a Request with an already consumed body, but Chrome's
implementation doesn't respect that yet.
mislav added a commit that referenced this pull request Jul 31, 2015
Allow passing a Request instance to Request constructor
@mislav
mislav merged commit d16df66 into master Jul 31, 2015
@mislav
mislav deleted the request-to-request branch July 31, 2015 17:32
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Request implementation

3 participants