Skip to content

Commit

Permalink
Don't overwrite old cookies on Set-Cookie
Browse files Browse the repository at this point in the history
When handling Set-Cookie headers, each request would previously
replace the entire `context->"cookie"` object. This would cause
consecutive responses with Set-Cookie headers to overwrite all existing
cookies in the context.
  • Loading branch information
reneegyllensvaan authored and fcsonline committed May 11, 2023
1 parent 1ff56ea commit dfd5548
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/actions/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,9 @@ impl Runnable for Request {
status,
});

if response.cookies().count() > 0 {
let mut cookies = Map::new();

for cookie in response.cookies() {
cookies.insert(cookie.name().to_string(), json!(cookie.value().to_string()));
}

context.insert("cookies".to_string(), json!(cookies));
for cookie in response.cookies() {
let cookies = context.entry("cookies").or_insert_with(|| json!({})).as_object_mut().unwrap();
cookies.insert(cookie.name().to_string(), json!(cookie.value().to_string()));
}

let data = if let Some(ref key) = self.assign {
Expand Down

0 comments on commit dfd5548

Please sign in to comment.