Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/download/download_request_core.h" | 5 #include "content/browser/download/download_request_core.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 // the server return the entire entity if the validator doesn't match. | 174 // the server return the entire entity if the validator doesn't match. |
| 175 // Last-Modified can be used in the absence of ETag as a validator if the | 175 // Last-Modified can be used in the absence of ETag as a validator if the |
| 176 // response headers satisfied the HttpUtil::HasStrongValidators() predicate. | 176 // response headers satisfied the HttpUtil::HasStrongValidators() predicate. |
| 177 // | 177 // |
| 178 // This function assumes that HasStrongValidators() was true and that the | 178 // This function assumes that HasStrongValidators() was true and that the |
| 179 // ETag and Last-Modified header values supplied are valid. | 179 // ETag and Last-Modified header values supplied are valid. |
| 180 request->SetExtraRequestHeaderByName( | 180 request->SetExtraRequestHeaderByName( |
| 181 "If-Range", has_etag ? params->etag() : params->last_modified(), true); | 181 "If-Range", has_etag ? params->etag() : params->last_modified(), true); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Downloads are treated as top level navigations. Hence the first-party | |
| 185 // origin for cookies is always based on the target URL and is updated on | |
| 186 // redirects. | |
| 187 request->set_first_party_for_cookies(params->url()); | |
| 188 request->set_first_party_url_policy( | |
| 189 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | |
| 190 request->set_initiator(params->initiator()); | |
|
clamy
2016/12/14 16:25:38
Sanity check: Does this happen before or after URL
asanka
2016/12/14 18:21:29
Yup. This happens prior to request->Start() being
| |
| 191 | |
| 184 for (const auto& header : params->request_headers()) | 192 for (const auto& header : params->request_headers()) |
| 185 request->SetExtraRequestHeaderByName(header.first, header.second, | 193 request->SetExtraRequestHeaderByName(header.first, header.second, |
| 186 false /*overwrite*/); | 194 false /*overwrite*/); |
| 187 | 195 |
| 188 DownloadRequestData::Attach(request.get(), params, download_id); | 196 DownloadRequestData::Attach(request.get(), params, download_id); |
| 189 return request; | 197 return request; |
| 190 } | 198 } |
| 191 | 199 |
| 192 DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, | 200 DownloadRequestCore::DownloadRequestCore(net::URLRequest* request, |
| 193 Delegate* delegate) | 201 Delegate* delegate) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 return DOWNLOAD_INTERRUPT_REASON_NONE; | 635 return DOWNLOAD_INTERRUPT_REASON_NONE; |
| 628 } | 636 } |
| 629 | 637 |
| 630 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT) | 638 if (http_headers.response_code() == net::HTTP_PARTIAL_CONTENT) |
| 631 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; | 639 return DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT; |
| 632 | 640 |
| 633 return DOWNLOAD_INTERRUPT_REASON_NONE; | 641 return DOWNLOAD_INTERRUPT_REASON_NONE; |
| 634 } | 642 } |
| 635 | 643 |
| 636 } // namespace content | 644 } // namespace content |
| OLD | NEW |