Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Request/Response BodyInit consuming #70

Merged
merged 2 commits into from
Jan 16, 2015

Conversation

josh
Copy link
Contributor

@josh josh commented Jan 15, 2015

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
} else if (!body) {
this._bodyText = ''
} else {
throw new Error('unsupported BodyInit type')
Copy link
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

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
Copy link

annevk commented Jan 16, 2015

@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
Copy link
Contributor Author

josh commented Jan 16, 2015

(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