aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/request.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-13 15:26:15 -0500
committerGitHub <noreply@github.com>2016-08-13 15:26:15 -0500
commit882872897e9473ec176d771589f64769fbd4c352 (patch)
treef113ef75ea151b74ef8722bfc79828cb51351044 /components/script/dom/request.rs
parent476df170453d2805ba4b9d138804c0b189679dc8 (diff)
parent26930277278c7f5bf4ab615f10ac2c802668688a (diff)
downloadservo-882872897e9473ec176d771589f64769fbd4c352.tar.gz
servo-882872897e9473ec176d771589f64769fbd4c352.zip
Auto merge of #12851 - jeenalee:request, r=nox
Fix step 31 of the Request constructor. <!-- Please describe your changes on the following line: --> This PR fixes the step 31 of the Request constructor to fill Request's Headers object and rethrow any exceptions. Additionally, it removes unnecessary line breaks, comments, and redundant function. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12845 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because this PR does not change the behavior of the Request constructor. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> In addition to fixing step 31 of the Request constructor, this commit also: - remove `get_current_url` function, and use `net_request::request`'s built-in `current_url` method - clean up unnecessary line breaks and comments <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12851) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/request.rs')
-rw-r--r--components/script/dom/request.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs
index 7f612157566..c396c0d36e1 100644
--- a/components/script/dom/request.rs
+++ b/components/script/dom/request.rs
@@ -32,7 +32,7 @@ use net_traits::request::Request as NetTraitsRequest;
use net_traits::request::RequestMode as NetTraitsRequestMode;
use net_traits::request::Type as NetTraitsRequestType;
use net_traits::request::{Origin, Window};
-use std::cell::{Cell, Ref};
+use std::cell::Cell;
use url::Url;
#[dom_struct]
@@ -144,7 +144,7 @@ impl Request {
// Step 12
let mut request: NetTraitsRequest;
request = net_request_from_global(global,
- get_current_url(&temporary_request).unwrap().clone(),
+ temporary_request.current_url(),
false);
request.method = temporary_request.method;
request.headers = temporary_request.headers.clone();
@@ -214,8 +214,6 @@ impl Request {
return Err(Error::Type(
"RequestInit's referrer has invalid origin".to_string()));
}
- // TODO: Requires Step 7.
-
// Step 14.7
*request.referer.borrow_mut() = NetTraitsRequestReferer::RefererUrl(parsed_referrer);
}
@@ -339,7 +337,7 @@ impl Request {
}
// Step 31
- r.Headers().fill(Some(HeadersOrByteStringSequenceSequence::Headers(headers_copy)));
+ try!(r.Headers().fill(Some(HeadersOrByteStringSequenceSequence::Headers(headers_copy))));
// Step 32
let input_body = if let RequestInfo::Request(ref input_request) = input {
@@ -433,16 +431,6 @@ fn net_request_from_global(global: GlobalRef,
Some(pipeline_id))
}
-// https://fetch.spec.whatwg.org/#concept-request-current-url
-fn get_current_url(req: &NetTraitsRequest) -> Option<Ref<Url>> {
- let url_list = req.url_list.borrow();
- if url_list.len() > 0 {
- Some(Ref::map(url_list, |urls| urls.last().unwrap()))
- } else {
- None
- }
-}
-
fn normalized_method_to_typed_method(m: &str) -> hyper::method::Method {
match m {
"DELETE" => hyper::method::Method::Delete,