We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1135751 commit 95228f5Copy full SHA for 95228f5
src/hyperapp.rs
@@ -82,13 +82,17 @@ pub fn get_http_method() -> Option<String> {
82
// Get a specific header from the current HTTP request
83
// Returns None if not in HTTP context or header doesn't exist
84
pub fn get_request_header(name: &str) -> Option<String> {
85
+ use http::header::HeaderName;
86
+
87
APP_HELPERS.with(|helpers| {
88
helpers
89
.borrow()
90
.current_http_context
91
.as_ref()
92
.and_then(|ctx| {
- ctx.request.headers().get(name)
93
+ // Convert string to HeaderName
94
+ let header_name = HeaderName::from_bytes(name.as_bytes()).ok()?;
95
+ ctx.request.headers().get(&header_name)
96
.and_then(|value| value.to_str().ok())
97
.map(|s| s.to_string())
98
})
0 commit comments