headers icon indicating copy to clipboard operation
headers copied to clipboard

Many header types are missing public constructors

Open jebrosen opened this issue 4 years ago • 2 comments

Per SergioBenitez/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?

jebrosen avatar Sep 10 '19 06:09 jebrosen

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?

seanmonstar avatar Sep 10 '19 16:09 seanmonstar

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!

jebrosen avatar Sep 10 '19 18:09 jebrosen