-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work to support x-forwarded-proto
Fix tests Undo automatic formatting Fix some typos Cleanup, fix docs Add proxy_secure Rename Protocol to ForwardedProtocol and improve config docs Rename ForwardedProtocol and forwarded_protocol to ProxyProto and proxy_proto. Implemented suggestions from PR Fix tests, remove unused config parameter in set_defaults Reorder from_hyp, fix local CookieJar Use UncasedStr in ProxyProtocol instead of owned variant
- Loading branch information
1 parent
b5278de
commit d1e8bc4
Showing
12 changed files
with
317 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::fmt; | ||
|
||
/// A protocol used to identify a specific protocol forwarded by an HTTP proxy. | ||
// Names are case-insensitive | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub enum ProxyProto<'a> { | ||
/// `http` value, Hypertext Transfer Protocol | ||
Http, | ||
/// `https` value, Hypertext Transfer Protocol Secure | ||
Https, | ||
/// Any other protocol name not known to us | ||
Unknown(&'a uncased::UncasedStr), | ||
} | ||
|
||
impl<'a> From<&'a str> for ProxyProto<'a> { | ||
fn from(s: &'a str) -> ProxyProto<'a> { | ||
match s.to_lowercase().as_str() { | ||
"http" => ProxyProto::Http, | ||
"https" => ProxyProto::Https, | ||
_ => ProxyProto::Unknown(s.into()), | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for ProxyProto<'_> { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str(match *self { | ||
ProxyProto::Http => "http", | ||
ProxyProto::Https => "https", | ||
ProxyProto::Unknown(s) => s.as_str(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.