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

Many header types are missing public constructors #48

Open
jebrosen opened this issue Sep 10, 2019 · 2 comments
Open

Many header types are missing public constructors #48

jebrosen opened this issue Sep 10, 2019 · 2 comments

Comments

@jebrosen
Copy link

Per rwf2/Rocket#1067 I looked into reexporting typed headers from this crate, as they were reexported from hyper 0.10 in the past. But I quickly discovered that many headers apparently can't be constructed, because they have a single private field and nothing like a new or from method.

In particular I was trying to use Location and ETag, but given #40 and after looking at the docs it looks like many other header types don't have public constructors either. Am I misunderstanding the purpose of this crate or misreading a trait bound, or are these simply missing constructors that need to be implemented?

@seanmonstar
Copy link
Member

Any missing constructors is due to not having spent the time to design one. Ideally the typed headers don't expose their internals, and a constructor validates that the type is correct. Would you like to help design constructor for those types?

@jebrosen
Copy link
Author

I think I understand the motivation then, and it makes some sense to me. Although it was a bit confusing to see so many header types "available" that I couldn't actually use. I will probably hold off on integrating something like this into Rocket until more constructors are implemented or I can gauge how many of which categories of headers are already usable.

Would you like to help design constructor for those types?

I'm definitely interested in doing so, but anything like a PR or code proposal might be a little while away. If anyone else is interested in doing them sooner than I can, please feel free!

fasterthanlime added a commit to fasterthanlime/headers that referenced this issue Mar 15, 2022
As far as I know, all URI characters should be valid Header value
characters, so we can have an infallible constructor for Location
from an `Uri`.

This doesn't cover all uses of the Location header, since it allows
URI-references like `/People.html#tim`, but it's an ergonomic win
already, as mentioned in hyperium#48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants