mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Differentiate between HTTP and non-HTTP APIs for cookie operations. Fix some incorrect cookie removal operation logic. Order the returned cookies according to the spec. Make cookie unit tests pass.
This commit is contained in:
parent
24c8896f88
commit
14df9f8a70
7 changed files with 142 additions and 137 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cookie_storage::CookieSource;
|
||||
use resource_task::{Metadata, TargetedLoadResponse, LoadData, start_sending_opt, ResponseSenders};
|
||||
use resource_task::ControlMsg;
|
||||
use resource_task::ProgressMsg::{Payload, Done};
|
||||
|
@ -108,7 +109,7 @@ reason: \"certificate verify failed\" }]";
|
|||
};
|
||||
|
||||
let (tx, rx) = channel();
|
||||
cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx));
|
||||
cookies_chan.send(ControlMsg::GetCookiesForUrl(url.clone(), tx, CookieSource::HTTP));
|
||||
if let Some(cookies) = rx.recv().unwrap() {
|
||||
let mut v = Vec::new();
|
||||
v.push(cookies.into_bytes());
|
||||
|
@ -189,7 +190,8 @@ reason: \"certificate verify failed\" }]";
|
|||
}
|
||||
|
||||
if let Some(&SetCookie(ref cookies)) = response.headers.get::<SetCookie>() {
|
||||
cookies_chan.send(ControlMsg::SetCookies(cookies.clone(), url.clone()));
|
||||
cookies_chan.send(ControlMsg::SetCookies(cookies.clone(), url.clone(),
|
||||
CookieSource::HTTP));
|
||||
}
|
||||
|
||||
if response.status.class() == StatusClass::Redirection {
|
||||
|
@ -219,6 +221,8 @@ reason: \"certificate verify failed\" }]";
|
|||
info!("redirecting to {}", new_url);
|
||||
url = new_url;
|
||||
|
||||
// According to https://tools.ietf.org/html/rfc7231#section-6.4.2,
|
||||
// historically UAs have rewritten POST->GET on 301 and 302 responses.
|
||||
if load_data.method == Method::Post &&
|
||||
(response.status == StatusCode::MovedPermanently ||
|
||||
response.status == StatusCode::Found) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue