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
|
@ -549,9 +549,9 @@ impl<S: 'static> TestRequest<S> {
|
||||||
|
|
||||||
/// set cookie of this request
|
/// set cookie of this request
|
||||||
pub fn cookie(mut self, cookie: Cookie<'static>) -> Self {
|
pub fn cookie(mut self, cookie: Cookie<'static>) -> Self {
|
||||||
|
if self.cookies.is_none() {
|
||||||
let mut should_insert = true;
|
let mut should_insert = true;
|
||||||
match &mut self.cookies {
|
let old_cookies = self.cookies.as_mut().unwrap();
|
||||||
Some(old_cookies) => {
|
|
||||||
for old_cookie in old_cookies.iter() {
|
for old_cookie in old_cookies.iter() {
|
||||||
if old_cookie == &cookie {
|
if old_cookie == &cookie {
|
||||||
should_insert = false
|
should_insert = false
|
||||||
|
@ -560,8 +560,8 @@ impl<S: 'static> TestRequest<S> {
|
||||||
if should_insert {
|
if should_insert {
|
||||||
old_cookies.push(cookie);
|
old_cookies.push(cookie);
|
||||||
};
|
};
|
||||||
}
|
} else {
|
||||||
None => {}
|
self.cookies = Some(vec![cookie]);
|
||||||
};
|
};
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue