-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Cookie Header should be Map-like #1145
Copy link
Copy link
Closed
Labels
A-headersArea: headers.Area: headers.
Description
We only ever receive headers like this: Cookie: foo=bar; session=sean; hello=world, and having that be a vector of ["foo=bar", "session=sean", "hello=world"] doesn't really help anyone.
Instead, anyone needing to accept cookies would only be looking for a certain name anyways, so this code would be more appropriate:
let maybe_session = req.headers().get::<Cookie>().map(|cookie| cookie.get("session"));Being a map also helps deal with a common mistake naïve users could make: duplicate names should just be dropped.
Creation of a Cookie header should likewise use a map-like interface.
let mut cookie = Cookie::new();
cookie.set("session", "sean");
// maybe an extend API also? Though we could easily defer to a later release
let pairs = [("foo", "bar"), ("hello", "world")];
cookie.extend(&pairs);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-headersArea: headers.Area: headers.