-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix #1067 by importing typed headers from hyperx #1535
Conversation
I think this PR is ready for review now, @jebrosen :-) I'm not entirely sure that the reexport of HyperxHeaderTrait is elegant enough, but there's a "Header" confusion to take into account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like this, but I think we can organize it a bit more nicely.
One thing I did realize while reviewing this is that hyperx
does not implement some of traits hyper
uses it for headers, cc #1498. That's one point in favor of headers
instead of hyperx
that I did not consider, depending on how we prioritize #1498.
@@ -1,4 +1,4 @@ | |||
//! Re-exported hyper HTTP library types. | |||
//! Re-exported hyper HTTP library types and hyperx typed headers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is actually a bit weird, now that I'm seeing it. Can we try moving the headers
parts into e.g. core/http/src/headers.rs
instead?
@@ -21,6 +21,9 @@ | |||
|
|||
/// Reexported http header types. | |||
pub mod header { | |||
use super::super::header::Header; | |||
pub use hyperx::header::Header as HyperxHeaderTrait; | |||
|
|||
macro_rules! import_http_headers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's simply remove these header names re-exported from http
. Typed headers should make most of them unneeded, and the only remaining benefit of import_http_headers
was that applications don't need to depend on http
directly.
There are a few places in rocket
that use these, which used typed headers in 0.4 and could use them again.
Authorization<Scheme>, | ||
ProxyAuthorization<Scheme> | ||
} | ||
// Note: SetCookie is missing, since it must be formatted as separate header lines... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one isn't too bad a loss - SetCookie
(and Cookie
) is typically done via CookieJar
.
@@ -21,6 +21,9 @@ | |||
|
|||
/// Reexported http header types. | |||
pub mod header { | |||
use super::super::header::Header; | |||
pub use hyperx::header::Header as HyperxHeaderTrait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in order to call HeaderName
, right? As far as I can tell we did not re-export this trait in 0.4, but it does seem useful since it can be imported in the example. The name is a bit awkward, though.
I’ll take another look at #1498 to see how this interacts. |
I've looked further at |
Both @SergioBenitez is #1498 enough of a concern that we should avoid using |
Ah, I was confused by a layer of turtles. Anyway, I'm giving #1498 a shot to see how big an impact it would have. |
I believe this is the single largest source of slowdown in request handling. We should do nothing to exacerbate the issue or further prolong its mending. |
I'm revisiting this and I am quite confused about where this ended up. @jespersm, why did it matter whether or not @SergioBenitez #1498 addressed handling of headers in the request, but didn't touch |
I don't think there's anything we can reasonably do about this, unfortunately. See hyperium/http#467. Hopefully we get a fix upstream. |
I am closing this due to lack of progress. Happy to revisit if all of the points raised above are addressed. |
First attempt patch for #1067.
Imports all typed headers from
hyperx
except "Set-Cookie" since it requires multiline format, and thus can't do simple to_string().Probably not a big deal since Rocket handles cookies through CookieJar mechanism.