Skip to content

Improve Request/Response BodyInit consuming - #70

Merged
josh merged 2 commits into
masterfrom
improved-body-mixin-consuming
Jan 16, 2015
Merged

josh merged 2 commits into
masterfrom
improved-body-mixin-consuming

Conversation

@josh

@josh josh commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

Both Request and Response can accept a number of BodyInit types and are supposed to be consumable via a number of mixin readers.

@annevk seems like we're missing a way to consume FormData types. Theres no way to turn it into a Blob or ArrayBuffer. new Response(formData).blob() is going to become a clever hack if nothing official defined.

@josh josh self-assigned this Jan 15, 2015
Comment thread fetch.js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk when handling BodyInit types, whats the correct way to handle unknown types? The spec just says "switch on object's type" with no default case.

Chrome Canary seems to just cast everything via toString().

new Response(function() {}).text()
// "function () {}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is because IDL handles it. And indeed, if there's a primitive value present that is what IDL defaults to.

@annevk

annevk commented Jan 16, 2015

Copy link
Copy Markdown

@josh you can iterate over FormData these days. But yes, the serialization is not exposed. Part of the reason is that its specification is not quite clear. That needs to be sorted at some point.

@josh

josh commented Jan 16, 2015

Copy link
Copy Markdown
Contributor Author
(new FormData())[Symbol.iterator] // undefined

Doesn't look even Canary or FF Nightly implement it yet.

Anyway, thanks again @annevk! I'll just proceed with those cases being unsupported.

josh added a commit that referenced this pull request Jan 16, 2015
Improve Request/Response BodyInit consuming
@josh
josh merged commit ba6cac7 into master Jan 16, 2015
@josh
josh deleted the improved-body-mixin-consuming branch January 16, 2015 18:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 4, 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.

2 participants