mirror of https://github.com/fafhrd91/actix-web
Fix: Should assign a new cookie vector if it doesn't exist
This commit is contained in:
parent
5eb4ee27e8
commit
2d2917b61f
24
src/test.rs
24
src/test.rs
|
@ -549,19 +549,19 @@ impl<S: 'static> TestRequest<S> {
|
|||
|
||||
/// set cookie of this request
|
||||
pub fn cookie(mut self, cookie: Cookie<'static>) -> Self {
|
||||
let mut should_insert = true;
|
||||
match &mut self.cookies {
|
||||
Some(old_cookies) => {
|
||||
for old_cookie in old_cookies.iter() {
|
||||
if old_cookie == &cookie {
|
||||
should_insert = false
|
||||
};
|
||||
if self.cookies.is_none() {
|
||||
let mut should_insert = true;
|
||||
let old_cookies = self.cookies.as_mut().unwrap();
|
||||
for old_cookie in old_cookies.iter() {
|
||||
if old_cookie == &cookie {
|
||||
should_insert = false
|
||||
};
|
||||
if should_insert {
|
||||
old_cookies.push(cookie);
|
||||
};
|
||||
}
|
||||
None => {}
|
||||
};
|
||||
if should_insert {
|
||||
old_cookies.push(cookie);
|
||||
};
|
||||
} else {
|
||||
self.cookies = Some(vec![cookie]);
|
||||
};
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue