diff --git a/src/client/request.rs b/src/client/request.rs index f04f402b7..a63d739aa 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -544,9 +544,21 @@ impl ClientRequestBuilder { // set cookies if let Some(ref jar) = self.cookies { - for cookie in jar.delta() { + let ncookies = jar.iter().count(); + if ncookies > 0 { + let mut payload = String::new(); + for (ix, cookie) in jar.iter().enumerate() { + payload.push_str(&cookie.name()); + payload.push('='); + payload.push_str(&cookie.value()); + // semi-colon delimited, except for final k-v pair + if ix < ncookies - 1 { + payload.push(';'); + payload.push(' '); + } + } request.headers.append( - header::COOKIE, HeaderValue::from_str(&cookie.to_string())?); + header::COOKIE, HeaderValue::from_str(&payload)?); } } request.body = body.into(); diff --git a/src/client/response.rs b/src/client/response.rs index cc401f8bd..944b4c839 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -82,12 +82,10 @@ impl ClientResponse { if self.as_ref().cookies.is_none() { let msg = self.as_mut(); let mut cookies = Vec::new(); - if let Some(val) = msg.headers.get(header::SET_COOKIE) { + for val in msg.headers.get_all(header::SET_COOKIE).iter() { let s = str::from_utf8(val.as_bytes()) .map_err(CookieParseError::from)?; - for cookie in s.split("; ") { - cookies.push(Cookie::parse_encoded(cookie)?.into_owned()); - } + cookies.push(Cookie::parse_encoded(s)?.into_owned()); } msg.cookies = Some(cookies) }