Commit a364dd1e authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download service: Adds the fetch_error_body flag in request params.


This CL exposes the content layer's fetch_error_body flag in download
service.

Bug: 765778
Change-Id: I2f9ea5b437387e6e1864fb1867436869b6348472
Reviewed-on: https://chromium-review.googlesource.com/707780Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510173}
parent 17376274
......@@ -166,6 +166,8 @@ void DownloadDriverImpl::Start(
download_url_params->set_transient(true);
download_url_params->set_method(request_params.method);
download_url_params->set_file_path(file_path);
if (request_params.fetch_error_body)
download_url_params->set_fetch_error_body(true);
download_manager_->DownloadUrl(std::move(download_url_params));
}
......
......@@ -18,4 +18,5 @@ message RequestParams {
optional string url = 1;
optional string method = 2;
repeated RequestHeader headers = 3;
optional bool fetch_error_body = 4;
}
......@@ -232,6 +232,7 @@ RequestParams ProtoConversions::RequestParamsFromProto(
RequestParams request_params;
request_params.url = GURL(proto.url());
request_params.method = proto.method();
request_params.fetch_error_body = proto.fetch_error_body();
for (int i = 0; i < proto.headers_size(); i++) {
protodb::RequestHeader header = proto.headers(i);
......@@ -245,6 +246,7 @@ void ProtoConversions::RequestParamsToProto(const RequestParams& request_params,
protodb::RequestParams* proto) {
proto->set_url(request_params.url.spec());
proto->set_method(request_params.method);
proto->set_fetch_error_body(request_params.fetch_error_body);
int i = 0;
net::HttpRequestHeaders::Iterator iter(request_params.request_headers);
......
......@@ -96,6 +96,7 @@ TEST_F(ProtoConversionsTest, RequestParamsWithHeadersConversion) {
RequestParams expected;
expected.url = GURL(TEST_URL);
expected.method = "GET";
expected.fetch_error_body = true;
expected.request_headers.SetHeader("key1", "value1");
expected.request_headers.SetHeader("key2", "value2");
......@@ -105,6 +106,7 @@ TEST_F(ProtoConversionsTest, RequestParamsWithHeadersConversion) {
EXPECT_EQ(expected.url, actual.url);
EXPECT_EQ(expected.method, actual.method);
EXPECT_EQ(expected.fetch_error_body, actual.fetch_error_body);
std::string out;
actual.request_headers.GetHeader("key1", &out);
......
......@@ -20,7 +20,9 @@ bool SchedulingParams::operator==(const SchedulingParams& rhs) const {
priority == rhs.priority && cancel_time == rhs.cancel_time;
}
RequestParams::RequestParams() : method("GET") {}
RequestParams::RequestParams() : method("GET"), fetch_error_body(false) {}
RequestParams::RequestParams(const RequestParams& other) = default;
DownloadParams::DownloadParams() : client(DownloadClient::INVALID) {}
......
......@@ -94,7 +94,7 @@ struct SchedulingParams {
struct RequestParams {
public:
RequestParams();
RequestParams(const RequestParams& other) = default;
RequestParams(const RequestParams& other);
~RequestParams() = default;
GURL url;
......@@ -102,6 +102,10 @@ struct RequestParams {
// The request method ("GET" is the default value).
std::string method;
net::HttpRequestHeaders request_headers;
// If the request will fetch HTTP error response body and treat them as
// a successful download.
bool fetch_error_body;
};
// The parameters that describe a download request made to the DownloadService.
......
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