Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: content/child/web_url_loader_impl.cc

Issue 1693183002: Move multipart resource handling to core/fetch (1/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup-preliminary
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/web_url_loader_impl.cc
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index bf31e7fe9486d1c6a15c414a380961d1ebf6a179..0170a19549ca6fd57d66c952076e6fdcab5641ed 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -83,6 +83,17 @@ namespace content {
namespace {
+// The list of response headers that we do not copy from the original
+// response when generating a WebURLResponse for a MIME payload.
+const char* kReplaceHeaders[] = {
+ "content-type",
+ "content-length",
+ "content-disposition",
+ "content-range",
+ "range",
+ "set-cookie"
+};
+
using HeadersVector = ResourceDevToolsInfo::HeadersVector;
// Converts timing data from |load_timing| to the format used by WebKit.
@@ -1160,4 +1171,46 @@ void WebURLLoaderImpl::setLoadingTaskRunner(
context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone()));
}
+bool WebURLLoaderImpl::ParseAdditionalHeaders(
hiroshige 2016/02/25 18:10:24 What is the reason to place ParseAdditionalHeaders
yhirano 2016/02/25 18:35:13 Because I want to use net:: functions.
hiroshige 2016/02/25 21:46:31 Hmm. The code around this has some issues: |kRepla
+ const char* bytes,
+ size_t size,
+ blink::WebURLResponse* response,
+ size_t* end) {
+ int headers_end_pos =
+ net::HttpUtil::LocateEndOfAdditionalHeaders(bytes, size, 0);
+
+ if (headers_end_pos < 0)
+ return false;
+
+ *end = headers_end_pos;
+ // Eat headers and prepend a status line as is required by
+ // HttpResponseHeaders.
+ std::string headers("HTTP/1.1 200 OK\r\n");
+ headers.append(bytes, headers_end_pos);
+
+ scoped_refptr<net::HttpResponseHeaders> response_headers =
+ new net::HttpResponseHeaders(
+ net::HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size()));
+
+ std::string mime_type;
+ response_headers->GetMimeType(&mime_type);
+ response->setMIMEType(WebString::fromUTF8(mime_type));
+
+ std::string charset;
+ response_headers->GetCharset(&charset);
+ response->setTextEncodingName(WebString::fromUTF8(charset));
+
+ // Copy headers listed in kReplaceHeaders to the response.
+ for (size_t i = 0; i < arraysize(kReplaceHeaders); ++i) {
+ std::string name(kReplaceHeaders[i]);
+ std::string value;
+ size_t iterator = 0;
+ while (response_headers->EnumerateHeader(&iterator, name, &value)) {
+ response->addHTTPHeaderField(WebString::fromLatin1(name),
+ WebString::fromLatin1(value));
+ }
+ }
+ return true;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698