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

Unified Diff: third_party/WebKit/Source/platform/network/HTTPParsers.cpp

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: More global-interface-listing*-expected.txt, urlencoded-parser-expected.txt Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 60b925029db11a41d0c22b37c0c6478617606c0f..494b38dba8eab63262f252f01cdc3dc4cc99fe1d 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) {
« no previous file with comments | « third_party/WebKit/Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698