servo: Merge #14105 - Stop unnecessarily wrapping the response argument to http_redirect_fetch in Rc (from servo:rm-rc); r=nox
authorMs2ger <Ms2ger@gmail.com>
Mon, 07 Nov 2016 11:47:37 -0600
changeset 340088 bf3d35dd2a8ff35321be71853dd9a74121ca9083
parent 340087 ce312a7532165b984d88c12e29b466a99123a10e
child 340089 1a45b7787ad825bc5b895d835b3ca90aba271b88
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #14105 - Stop unnecessarily wrapping the response argument to http_redirect_fetch in Rc (from servo:rm-rc); r=nox Source-Repo: https://github.com/servo/servo Source-Revision: 3b5d1f2814bcac1432e0ee8e4c079d23fcfdc280
servo/components/net/fetch/methods.rs
--- a/servo/components/net/fetch/methods.rs
+++ b/servo/components/net/fetch/methods.rs
@@ -602,17 +602,17 @@ fn http_fetch<UI: 'static + UIProvider>(
             response = match request.redirect_mode.get() {
                 RedirectMode::Error => Response::network_error(NetworkError::Internal("Redirect mode error".into())),
                 RedirectMode::Manual => {
                     response.to_filtered(ResponseType::OpaqueRedirect)
                 },
                 RedirectMode::Follow => {
                     // set back to default
                     response.return_internal.set(true);
-                    http_redirect_fetch(request, cache, Rc::new(response),
+                    http_redirect_fetch(request, cache, response,
                                         cors_flag, target, done_chan, context)
                 }
             }
         },
 
         // Code 401
         Some(StatusCode::Unauthorized) => {
             // Step 1
@@ -672,28 +672,28 @@ fn http_fetch<UI: 'static + UIProvider>(
     response.return_internal.set(true);
     // Step 7
     response
 }
 
 /// [HTTP redirect fetch](https://fetch.spec.whatwg.org#http-redirect-fetch)
 fn http_redirect_fetch<UI: 'static + UIProvider>(request: Rc<Request>,
                                                  cache: &mut CORSCache,
-                                                 response: Rc<Response>,
+                                                 response: Response,
                                                  cors_flag: bool,
                                                  target: &mut Target,
                                                  done_chan: &mut DoneChannel,
                                                  context: &FetchContext<UI>)
                                                  -> Response {
     // Step 1
     assert_eq!(response.return_internal.get(), true);
 
     // Step 2
     if !response.actual_response().headers.has::<Location>() {
-        return Rc::try_unwrap(response).ok().unwrap();
+        return response;
     }
 
     // Step 3
     let location = match response.actual_response().headers.get::<Location>() {
         Some(&Location(ref location)) => location.clone(),
         _ => return Response::network_error(NetworkError::Internal("Location header parsing failure".into()))
     };
     let response_url = response.actual_response().url.as_ref().unwrap();