-
Notifications
You must be signed in to change notification settings - Fork 154
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
Identifiers #629
Comments
In fact, several existing header fields use angle brackets as delimiters for URI (references) (Link, Dav, If). SH tries to get away with one delimiter syntax, so quoted-string it is. |
Given how common URLs and origins seem to be as primitive components of headers headers, perhaps splitting them out into a type distinct from "string" might make sense. The initial serialisation might even be the same, but perhaps an eventual binary format could do more interesting tricks given knowledge of the format. |
An alternative way of stating OP would be asking why identifiers are as restricted as they are in the proposal? (I'm not entirely convinced either origin or URL is common enough to warrant its own type, FWIW.) |
origin is a URI (reference), no? It's quite common that certain delimiters are not allowed in identifiers. I assume we're discussing characters such as ":" and "/"? |
If you parse an origin as a URL and then serialize it, it would not be equal to the original input (it would have a trailing slash). And an opaque origin serializes as As for what's under discussion: "/" is already allowed. So ":" and ".", mainly, I think, but I'd have to double check if that's all. |
Depends on what you parse and serialize it with. FWIW, how does that matter in this context?
It parses as URI reference.
Hmm. https://greenbytes.de/tech/webdav/draft-ietf-httpbis-header-structure-04.html#identifier:
So I don't see ":" and "." here. |
Right, that's the issue. |
Well, you'd need more characters to be allowed so that an origin always is an identifier, no? (for instance: ",") |
Maybe, see whatwg/url#390. I agree that if we need to continue to allow "," in hosts we better stick to strings. Even then I'm still interested in hearing the rationale behind the characters allowed in identifiers. |
Identifiers aren't intended for payload; note that in the latest draft, they're only used for parameters and dictionaries. Everything else that's string-y needs to be quoted strings. If we added an URL type, it would almost certainly be delimited with angle brackets, since DQUOTE is already taken, and it needs to be both signalled and delimited in some fashion. It sounds like the underlying requirement here is "it has to look exactly like previous headers", which is a difficult bar to meet. What's the actual problem with using a string? |
I guess that answers one question I had for Which is also the problem. Using identifiers requires a very simple parser. And when we use origins we don't want to parse them as origins, but we want to compare them byte-for-byte. So all we'd need is split on "," and trim HTTP whitespace. With strings it's a little more involved and they would be harder to adopt now without all the structured header infrastructure in place. (And unfortunately as these things go everyone wants to ship stuff now.) |
Shipping code that doesn't implement SH but specifying it as SH seems pretty bad, both for your spec and for SH interop. Re-adding identifiers (or something like them) to the possible types in SH is certainly possible, though. |
That's why I said forward compatible. I'm not specifying it as SH as that's still somewhat in flux, but ideally if we extend And I was also thinking that if identifiers were broad enough, we could use them for a variety of CORS headers too, as pretty much all have a very basic syntax where they just take one or more identifier-likes. |
OK. Happy to re-add them if there's desire (although I might distinguish between those we use for dicts and params and those that are allowed in item; will see) -- just ask. |
I think if we could make all of https://fetch.spec.whatwg.org/#http-new-header-syntax structured headers that'd be great. |
The way I solved that in https://mimesniff.spec.whatwg.org/#serializing-a-mime-type is by serializing as identifier if there are no problematic code points and as a string otherwise. The parser would always produce a string, too. I think that's what I'd recommend doing, provided there's agreement to uplift some existing (and recently defined) headers to this scheme. |
@mikewest suggested using structured headers for Cross-Origin-Resource-Policy in whatwg/fetch#733 which makes sense, but requiring origins to be embedded in strings seems rather awkward and doesn't have precedent with the existing headers.
The text was updated successfully, but these errors were encountered: