-
Notifications
You must be signed in to change notification settings - Fork 90
Add a new constructor and an accessor to Upgrade
#105
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,23 @@ impl Upgrade { | |
pub fn websocket() -> Upgrade { | ||
Upgrade(HeaderValue::from_static("websocket")) | ||
} | ||
|
||
/// Constructs an `Upgrade: HTTP/2.0` header. | ||
pub fn http2() -> Upgrade { | ||
// must be uppercase, see | ||
// <https://datatracker.ietf.org/doc/html/rfc7230#section-2.6> | ||
Upgrade(HeaderValue::from_static("HTTP/2.0")) | ||
} | ||
|
||
/// Constructs an `Upgrade` header with the given `HeaderValue` | ||
pub fn new(value: HeaderValue) -> Upgrade { | ||
Upgrade(value) | ||
} | ||
|
||
/// Returns the header value, e.g. "websocket" or "HTTP/2.0", or a | ||
/// comma-separated list of protocols, see RFC 7230: | ||
/// <https://datatracker.ietf.org/doc/html/rfc7230#section-6.7> | ||
pub fn value(&self) -> &HeaderValue { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the typed headers don't hold onto a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. For now I changed it to return an Option<&str> instead. |
||
&self.0 | ||
} | ||
} |
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.
The spec says the header value would be
h2c
.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.
But I'm not sure we need this, it's not really used.
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.
Understood - I added an
h2c
constructor for that case and noted that ALPN/prior knowledge are overwhelmingly more common for the "http/2 over TLS" case.