Chromium Code Reviews| Index: components/offline_pages/core/prefetch/prefetch_request_fetcher.cc |
| diff --git a/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc b/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc |
| index 039faf1d36cbaeb7c435cd13448a9bd3255f80fc..b2cb2a88ed7223e713ff0facd4f7d41f29e14639 100644 |
| --- a/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc |
| +++ b/components/offline_pages/core/prefetch/prefetch_request_fetcher.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/logging.h" |
| #include "net/base/load_flags.h" |
| +#include "net/http/http_request_headers.h" |
| #include "net/http/http_status_code.h" |
| #include "net/traffic_annotation/network_traffic_annotation.h" |
| #include "net/url_request/url_fetcher.h" |
| @@ -16,11 +17,18 @@ |
| namespace offline_pages { |
| namespace { |
| + |
| +const char kPrefetchSever[] = |
| + "http://staging-offlinepages-pa.sandbox.googleapis.com/"; |
| + |
| +// Content type needed in order to communicate with the server in binary |
| +// proto format. |
| const char kRequestContentType[] = "application/x-protobuf"; |
| + |
| } // namespace |
| PrefetchRequestFetcher::PrefetchRequestFetcher( |
| - const GURL& url, |
| + const std::string& url_path, |
| const std::string& message, |
| net::URLRequestContextGetter* request_context_getter, |
| const FinishedCallback& callback) |
| @@ -46,12 +54,21 @@ PrefetchRequestFetcher::PrefetchRequestFetcher( |
| policy_exception_justification: |
| "Not implemented, considered not useful." |
| })"); |
| - url_fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::POST, this, |
| - traffic_annotation); |
| + url_fetcher_ = net::URLFetcher::Create( |
| + GURL(kPrefetchSever + url_path), |
|
dewittj
2017/05/16 18:30:20
This feels like it should be more like
GURL::Repl
jianli
2017/05/16 22:44:40
Since both server and path are hard coded constant
dewittj
2017/05/16 23:06:22
URL path is not hard coded in the GET case, correc
jianli
2017/05/16 23:52:33
Make sense. Done.
|
| + message.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, this, |
| + traffic_annotation); |
| url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| url_fetcher_->SetAutomaticallyRetryOn5xx(false); |
| url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(0); |
| - url_fetcher_->SetUploadData(kRequestContentType, message); |
| + if (message.empty()) { |
| + std::string extra_header(net::HttpRequestHeaders::kContentType); |
| + extra_header += ": "; |
| + extra_header += kRequestContentType; |
| + url_fetcher_->AddExtraRequestHeader(extra_header); |
| + } else { |
| + url_fetcher_->SetUploadData(kRequestContentType, message); |
| + } |
| url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| net::LOAD_DO_NOT_SAVE_COOKIES); |
| url_fetcher_->Start(); |