Commit 364fed76 authored by dalecurtis's avatar dalecurtis Committed by Commit bot

Use range request for CORS access check on Android.

Avoids unnecessarily downloading data which will be unused.

BUG=400788
TEST=none

Review URL: https://codereview.chromium.org/485023003

Cr-Commit-Position: refs/heads/master@{#291944}
parent c6827dc1
...@@ -22,6 +22,7 @@ using blink::WebURLResponse; ...@@ -22,6 +22,7 @@ using blink::WebURLResponse;
namespace content { namespace content {
static const int kHttpOK = 200; static const int kHttpOK = 200;
static const int kHttpPartialContentOK = 206;
MediaInfoLoader::MediaInfoLoader( MediaInfoLoader::MediaInfoLoader(
const GURL& url, const GURL& url,
...@@ -50,6 +51,12 @@ void MediaInfoLoader::Start(blink::WebFrame* frame) { ...@@ -50,6 +51,12 @@ void MediaInfoLoader::Start(blink::WebFrame* frame) {
request.setRequestContext(WebURLRequest::RequestContextVideo); request.setRequestContext(WebURLRequest::RequestContextVideo);
frame->setReferrerForRequest(request, blink::WebURL()); frame->setReferrerForRequest(request, blink::WebURL());
// Since we don't actually care about the media data at this time, use a two
// byte range request to avoid unnecessarily downloading resources. Not all
// servers support HEAD unfortunately, so use a range request; which is no
// worse than the previous request+cancel code. See http://crbug.com/400788
request.addHTTPHeaderField("Range", "bytes=0-1");
scoped_ptr<WebURLLoader> loader; scoped_ptr<WebURLLoader> loader;
if (test_loader_) { if (test_loader_) {
loader = test_loader_.Pass(); loader = test_loader_.Pass();
...@@ -123,7 +130,8 @@ void MediaInfoLoader::didReceiveResponse( ...@@ -123,7 +130,8 @@ void MediaInfoLoader::didReceiveResponse(
DidBecomeReady(kOk); DidBecomeReady(kOk);
return; return;
} }
if (response.httpStatusCode() == kHttpOK) { if (response.httpStatusCode() == kHttpOK ||
response.httpStatusCode() == kHttpPartialContentOK) {
DidBecomeReady(kOk); DidBecomeReady(kOk);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment