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

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

Issue 2292763002: [Fetch API] Implement Request.formData and Response.formData. (Closed)
Patch Set: Created 3 years, 11 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: 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 bd5257dece6b4a7ce03560d17ba556f50cd38c51..866c8f1942dc884c631dbc54aa78e8a9f7c5f9d2 100644
--- a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
+++ b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp
@@ -34,6 +34,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
+#include "platform/HTTPNames.h"
#include "platform/json/JSONParser.h"
#include "platform/network/ResourceResponse.h"
#include "platform/weborigin/Suborigin.h"
@@ -898,6 +899,47 @@ bool parseMultipartHeadersFromBody(const char* bytes,
return true;
}
+bool parseMultipartFormHeadersFromBody(const char* bytes,
+ size_t size,
+ HTTPHeaderMap* headerFields,
+ size_t* end) {
+ DCHECK_EQ(0u, headerFields->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 headers to the response.
+ const AtomicString* const headerNamePointers[] = {
+ &HTTPNames::Content_Disposition, &HTTPNames::Content_Transfer_Encoding,
+ &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)) {
+ headerFields->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 maxParseDepth) {

Powered by Google App Engine
This is Rietveld 408576698