Commit 12b4a561 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Make webview code use two argument ResponseHeader manipulation calls

We want to get rid of the single argument AddHeader() method as the two
argument AddHeader() and SetHeader() methods are safer and more
flexible.

Change-Id: Id6a5288d453e0e7d8bbe59cc1938f5a14f79d3bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147674
Auto-Submit: Matt Menke <mmenke@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758949}
parent a6a899b4
......@@ -32,8 +32,9 @@ namespace android_webview {
namespace {
const char kResponseHeaderViaShouldInterceptRequest[] =
"Client-Via: shouldInterceptRequest";
const char kResponseHeaderViaShouldInterceptRequestName[] = "Client-Via";
const char kResponseHeaderViaShouldInterceptRequestValue[] =
"shouldInterceptRequest";
const char kHTTPOkText[] = "OK";
const char kHTTPNotFoundText[] = "Not Found";
......@@ -237,12 +238,8 @@ void AndroidStreamReaderURLLoader::HeadersComplete(
&head.charset);
if (expected_content_size_ != -1) {
std::string content_length_header(
net::HttpRequestHeaders::kContentLength);
content_length_header.append(": ");
content_length_header.append(
base::NumberToString(expected_content_size_));
head.headers->AddHeader(content_length_header);
head.headers->SetHeader(net::HttpRequestHeaders::kContentLength,
base::NumberToString(expected_content_size_));
head.content_length = expected_content_size_;
}
......@@ -251,10 +248,7 @@ void AndroidStreamReaderURLLoader::HeadersComplete(
env, resource_request_.url,
input_stream_reader_wrapper_->input_stream(), &mime_type) &&
!mime_type.empty()) {
std::string content_type_header(net::HttpRequestHeaders::kContentType);
content_type_header.append(": ");
content_type_header.append(mime_type);
head.headers->AddHeader(content_type_header);
head.headers->SetHeader(net::HttpRequestHeaders::kContentType, mime_type);
head.mime_type = mime_type;
}
}
......@@ -264,7 +258,8 @@ void AndroidStreamReaderURLLoader::HeadersComplete(
// Indicate that the response had been obtained via shouldInterceptRequest.
// TODO(jam): why is this added for protocol handler (e.g. content scheme and
// file resources?). The old path does this as well.
head.headers->AddHeader(kResponseHeaderViaShouldInterceptRequest);
head.headers->SetHeader(kResponseHeaderViaShouldInterceptRequestName,
kResponseHeaderViaShouldInterceptRequestValue);
SendBody();
}
......
......@@ -136,10 +136,7 @@ class TestResponseDelegate
return;
}
headers->ReplaceStatusLine(custom_status_);
std::string header_line(custom_header_name_);
header_line.append(": ");
header_line.append(custom_header_value_);
headers->AddHeader(header_line);
headers->AddHeader(custom_header_name_, custom_header_value_);
}
private:
......
......@@ -104,10 +104,7 @@ bool AwWebResourceResponse::GetResponseHeaders(
&header_values);
DCHECK_EQ(header_values.size(), header_names.size());
for (size_t i = 0; i < header_names.size(); ++i) {
std::string header_line(header_names[i]);
header_line.append(": ");
header_line.append(header_values[i]);
headers->AddHeader(header_line);
headers->AddHeader(header_names[i], header_values[i]);
}
return true;
}
......
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