rest: add cookie_from_header helper
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
5d74f79643
commit
e5e48b01ad
|
@ -201,6 +201,16 @@ pub fn extract_cookie(cookie: &str, cookie_name: &str) -> Option<String> {
|
|||
None
|
||||
}
|
||||
|
||||
/// Extract a specific cookie from a HeaderMap's "COOKIE" entry.
|
||||
/// We assume cookie_name is already url encoded.
|
||||
pub fn cookie_from_header(headers: &http::HeaderMap, cookie_name: &str) -> Option<String> {
|
||||
if let Some(Ok(cookie)) = headers.get("COOKIE").map(|v| v.to_str()) {
|
||||
extract_cookie(&cookie, cookie_name)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// normalize uri path
|
||||
///
|
||||
/// Do not allow ".", "..", or hidden files ".XXXX"
|
||||
|
|
Loading…
Reference in New Issue