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

Should web_sys::Headers allow opaque bytes? #1287

Open
liamcurry opened this issue Feb 22, 2019 · 2 comments
Open

Should web_sys::Headers allow opaque bytes? #1287

liamcurry opened this issue Feb 22, 2019 · 2 comments
Labels
breaking-change Tracking breaking changes for the next major version bump (if ever) frontend:webidl Issues related to the WebIDL frontend to wasm-bindgen web-sys Issues related to the `web-sys` crate

Comments

@liamcurry
Copy link
Contributor

liamcurry commented Feb 22, 2019

I'm writing some code to convert an http::Request to a web_sys::Request, and I noticed in the http crate there is a struct HeaderValue with this note:

In practice, HTTP header field values are usually valid ASCII. However, the HTTP spec allows for a header value to contain opaque bytes as well. In this case, the header field value is not able to be represented as a string.

The functions for web_sys::Headers don't take this into account and all rely on strings. Would that be considered a bug? If not then please feel welcome to close this issue. Thanks!

@fitzgen fitzgen added frontend:webidl Issues related to the WebIDL frontend to wasm-bindgen web-sys Issues related to the `web-sys` crate breaking-change Tracking breaking changes for the next major version bump (if ever) labels Feb 22, 2019
@fitzgen
Copy link
Member

fitzgen commented Feb 22, 2019

The Web IDL for Headers#set takes a ByteString which is "the set of all possible sequences of bytes", so yes it seems we should allow passing arbitrary slices here.

However, we translate ByteString to &str in our Web IDL frontend. I can't remember if there is a particular reason for that, or if this is just an oversight. +cc @alexcrichton

@alexcrichton
Copy link
Contributor

This was configured in #511 and was intended to match the documentation at https://developer.mozilla.org/en-US/docs/Web/API/ByteString. This may be a WebIDL/JS mismatch?

One thing we could do, if JS supports it, is also generate methods taking Uint8Array if a ByteString is accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Tracking breaking changes for the next major version bump (if ever) frontend:webidl Issues related to the WebIDL frontend to wasm-bindgen web-sys Issues related to the `web-sys` crate
Projects
None yet
Development

No branches or pull requests

3 participants