http-rs / http-rs/tide

Cookies are set multiple times when using *server.nest*

Open
#396 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
5.1k
Forks
329
PR merge metrics
No merged PRs in 30d

Description

When setting a cookie in a nested service it is set multiple times depending on the level of the nested service. For example:

```rust
use async_std::task;
use cookie::Cookie;
use tide::{self, Response};

fn main() {
task::block_on(async {
let mut inner = tide::new();
inner.at("/3").get(|_| async {
let mut r = Response::new(200);
r.set_cookie(Cookie::new("snack", "tuna"));
r.body_string(String::from("ok"))
});

let mut second = tide::new();
second.at("/2").nest(inner);

let mut outer = tide::new();
outer.at("/1").nest(second);

outer
.listen("localhost:8080")
.await
.expect("Error starting the server");
})
}
```
When `GET localhost:8080/1/2/3` the response is
```
HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
set-cookie: snack=tuna,snack=tuna,snack=tuna
transfer-encoding: chunked
date: Fri, 31 Jan 2020 10:39:54 GMT

ok
```

The cookie is set 3 times.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.