Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jeenalee committed Oct 27, 2016
1 parent 94ea24e commit baacc69
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions components/script/dom/request.rs
Expand Up @@ -40,6 +40,7 @@ use std::cell::{Cell, Ref};
use std::rc::Rc;
use url::Url;

use dom::bindings::js::RootedReference;
#[dom_struct]
pub struct Request {
reflector_: Reflector,
Expand Down Expand Up @@ -326,8 +327,13 @@ impl Request {
}

// Step 29
// When r.Headers()'s header list is emptied,
// r.Headers that was filled in Step 28 becomes empty.
// We cannot empty `r.Headers().header_list` because
// we would undo the Step 27 above. One alternative is to set
// `headers_copy` as a deep copy of `r.Headers()`. However,
// `r.Headers()` is a `Root<T>`, and therefore it is difficult
// to obtain a mutable reference to `r.Headers()`. Without the
// mutable reference, we cannot mutate `r.Headers()` to be the
// deep copied headers in Step 27.

// Step 30
if r.request.borrow().mode == NetTraitsRequestMode::NoCORS {
Expand All @@ -346,19 +352,18 @@ impl Request {
}

// Step 31
if let Some(HeadersInit::Headers(_)) = init.headers {
try!(r.Headers().fill(Some(HeadersInit::Headers(headers_copy))));
};

// This is equivalent to the specification's concept of
// "associated headers list". If an init headers is not given,
// but an input with headers is given, set request's
// headers as the input's Headers.
if let None = init.headers {
if let RequestInfo::Request(ref input_request) = input {
try!(r.Headers().fill(Some(HeadersInit::Headers(input_request.Headers()))));
}
};
match init.headers {
None => {
// This is equivalent to the specification's concept of
// "associated headers list". If an init headers is not given,
// but an input with headers is given, set request's
// headers as the input's Headers.
if let RequestInfo::Request(ref input_request) = input {
try!(r.Headers().fill(Some(HeadersInit::Headers(input_request.Headers()))));
}
},
Some(_) => try!(r.Headers().fill(Some(HeadersInit::Headers(headers_copy)))),
}

// Step 32
let mut input_body = if let RequestInfo::Request(ref input_request) = input {
Expand Down

0 comments on commit baacc69

Please sign in to comment.