| Index: third_party/WebKit/Source/platform/network/HTTPParsers.cpp
|
| diff --git a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
|
| index d26f7e5e90c6d6c569ac3b58c5971cf5c8813d12..0c1496df5d766a4ae75b0f0e9ded041f01c43541 100644
|
| --- a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
|
| +++ b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
|
| @@ -35,6 +35,7 @@
|
| #include "net/http/http_content_disposition.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/http/http_util.h"
|
| +#include "platform/HTTPNames.h"
|
| #include "platform/json/JSONParser.h"
|
| #include "platform/loader/fetch/ResourceResponse.h"
|
| #include "platform/weborigin/Suborigin.h"
|
| @@ -828,6 +829,46 @@ bool ParseMultipartHeadersFromBody(const char* bytes,
|
| return true;
|
| }
|
|
|
| +bool ParseMultipartFormHeadersFromBody(const char* bytes,
|
| + size_t size,
|
| + HTTPHeaderMap* header_fields,
|
| + size_t* end) {
|
| + DCHECK_EQ(0u, header_fields->size());
|
| +
|
| + int headersEndPos =
|
| + net::HttpUtil::LocateEndOfAdditionalHeaders(bytes, size, 0);
|
| +
|
| + if (headersEndPos < 0)
|
| + return false;
|
| +
|
| + *end = headersEndPos;
|
| +
|
| + // 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, headersEndPos);
|
| +
|
| + scoped_refptr<net::HttpResponseHeaders> responseHeaders =
|
| + new net::HttpResponseHeaders(
|
| + net::HttpUtil::AssembleRawHeaders(headers.data(), headers.length()));
|
| +
|
| + // Copy selected header fields.
|
| + const AtomicString* const headerNamePointers[] = {
|
| + &HTTPNames::Content_Disposition, &HTTPNames::Content_Type};
|
| + for (const AtomicString* headerNamePointer : headerNamePointers) {
|
| + StringUTF8Adaptor adaptor(*headerNamePointer);
|
| + size_t iterator = 0;
|
| + base::StringPiece headerNameStringPiece = adaptor.AsStringPiece();
|
| + std::string value;
|
| + while (responseHeaders->EnumerateHeader(&iterator, headerNameStringPiece,
|
| + &value)) {
|
| + header_fields->Add(*headerNamePointer, WebString::FromUTF8(value));
|
| + }
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| // See https://tools.ietf.org/html/draft-ietf-httpbis-jfv-01, Section 4.
|
| std::unique_ptr<JSONArray> ParseJSONHeader(const String& header,
|
| int max_parse_depth) {
|
|
|