Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 1304183006: Fail preflight request when redirect is received (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // to content::WebURLLoaderImpl. So, this loader must also get detached from 307 // to content::WebURLLoaderImpl. So, this loader must also get detached from
308 // the resource by calling clearResource(). 308 // the resource by calling clearResource().
309 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse) 309 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse)
310 { 310 {
311 ASSERT(m_client); 311 ASSERT(m_client);
312 ASSERT_UNUSED(resource, resource == this->resource()); 312 ASSERT_UNUSED(resource, resource == this->resource());
313 ASSERT(m_async); 313 ASSERT(m_async);
314 314
315 RefPtr<DocumentThreadableLoader> protect(this); 315 RefPtr<DocumentThreadableLoader> protect(this);
316 316
317 if (m_actualRequest) {
318 reportResponseReceived(resource->identifier(), redirectResponse);
319
320 clearResource();
321 request = ResourceRequest();
322
323 m_requestStartedSeconds = 0.0;
324
325 handlePreflightFailure(redirectResponse.url().string(), "Response for pr eflight is invalid (redirect)");
326
327 return;
328 }
329
317 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) { 330 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) {
318 // We use |m_redirectMode| to check the original redirect mode. 331 // We use |m_redirectMode| to check the original redirect mode.
319 // |request| is a new request for redirect. So we don't set the redirect 332 // |request| is a new request for redirect. So we don't set the redirect
320 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect(). 333 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect().
321 ASSERT(request.useStreamOnResponse()); 334 ASSERT(request.useStreamOnResponse());
322 // There is no need to read the body of redirect response because there 335 // There is no need to read the body of redirect response because there
323 // is no way to read the body of opaque-redirect filtered response's 336 // is no way to read the body of opaque-redirect filtered response's
324 // internal response. 337 // internal response.
325 // TODO(horo): If we support any API which expose the internal body, we 338 // TODO(horo): If we support any API which expose the internal body, we
326 // will have to read the body. And also HTTPCache changes will be needed 339 // will have to read the body. And also HTTPCache changes will be needed
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 return DoNotAllowStoredCredentials; 751 return DoNotAllowStoredCredentials;
739 return m_resourceLoaderOptions.allowCredentials; 752 return m_resourceLoaderOptions.allowCredentials;
740 } 753 }
741 754
742 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 755 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
743 { 756 {
744 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); 757 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin ();
745 } 758 }
746 759
747 } // namespace blink 760 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/xmlhttprequest/access-control-and-redirects-async-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698