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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Google Inc. All rights reserved.
6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 17 matching lines...) Expand all
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 #include "platform/network/HTTPParsers.h" 33 #include "platform/network/HTTPParsers.h"
34 34
35 #include "net/http/http_content_disposition.h" 35 #include "net/http/http_content_disposition.h"
36 #include "net/http/http_response_headers.h" 36 #include "net/http/http_response_headers.h"
37 #include "net/http/http_util.h" 37 #include "net/http/http_util.h"
38 #include "platform/HTTPNames.h"
38 #include "platform/json/JSONParser.h" 39 #include "platform/json/JSONParser.h"
39 #include "platform/loader/fetch/ResourceResponse.h" 40 #include "platform/loader/fetch/ResourceResponse.h"
40 #include "platform/weborigin/Suborigin.h" 41 #include "platform/weborigin/Suborigin.h"
41 #include "platform/wtf/DateMath.h" 42 #include "platform/wtf/DateMath.h"
42 #include "platform/wtf/MathExtras.h" 43 #include "platform/wtf/MathExtras.h"
43 #include "platform/wtf/text/CString.h" 44 #include "platform/wtf/text/CString.h"
44 #include "platform/wtf/text/CharacterNames.h" 45 #include "platform/wtf/text/CharacterNames.h"
45 #include "platform/wtf/text/ParsingUtilities.h" 46 #include "platform/wtf/text/ParsingUtilities.h"
46 #include "platform/wtf/text/StringBuilder.h" 47 #include "platform/wtf/text/StringBuilder.h"
47 #include "platform/wtf/text/StringUTF8Adaptor.h" 48 #include "platform/wtf/text/StringUTF8Adaptor.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 822
822 response->ClearHTTPHeaderField(header); 823 response->ClearHTTPHeaderField(header);
823 while (response_headers->EnumerateHeader(&iterator, header_string_piece, 824 while (response_headers->EnumerateHeader(&iterator, header_string_piece,
824 &value)) { 825 &value)) {
825 response->AddHTTPHeaderField(header, WebString::FromLatin1(value)); 826 response->AddHTTPHeaderField(header, WebString::FromLatin1(value));
826 } 827 }
827 } 828 }
828 return true; 829 return true;
829 } 830 }
830 831
832 bool ParseMultipartFormHeadersFromBody(const char* bytes,
833 size_t size,
834 HTTPHeaderMap* header_fields,
835 size_t* end) {
836 DCHECK_EQ(0u, header_fields->size());
837
838 int headersEndPos =
839 net::HttpUtil::LocateEndOfAdditionalHeaders(bytes, size, 0);
840
841 if (headersEndPos < 0)
842 return false;
843
844 *end = headersEndPos;
845
846 // Eat headers and prepend a status line as is required by
847 // HttpResponseHeaders.
848 std::string headers("HTTP/1.1 200 OK\r\n");
849 headers.append(bytes, headersEndPos);
850
851 scoped_refptr<net::HttpResponseHeaders> responseHeaders =
852 new net::HttpResponseHeaders(
853 net::HttpUtil::AssembleRawHeaders(headers.data(), headers.length()));
854
855 // Copy selected header fields.
856 const AtomicString* const headerNamePointers[] = {
857 &HTTPNames::Content_Disposition, &HTTPNames::Content_Type};
858 for (const AtomicString* headerNamePointer : headerNamePointers) {
859 StringUTF8Adaptor adaptor(*headerNamePointer);
860 size_t iterator = 0;
861 base::StringPiece headerNameStringPiece = adaptor.AsStringPiece();
862 std::string value;
863 while (responseHeaders->EnumerateHeader(&iterator, headerNameStringPiece,
864 &value)) {
865 header_fields->Add(*headerNamePointer, WebString::FromUTF8(value));
866 }
867 }
868
869 return true;
870 }
871
831 // See https://tools.ietf.org/html/draft-ietf-httpbis-jfv-01, Section 4. 872 // See https://tools.ietf.org/html/draft-ietf-httpbis-jfv-01, Section 4.
832 std::unique_ptr<JSONArray> ParseJSONHeader(const String& header, 873 std::unique_ptr<JSONArray> ParseJSONHeader(const String& header,
833 int max_parse_depth) { 874 int max_parse_depth) {
834 StringBuilder sb; 875 StringBuilder sb;
835 sb.Append("["); 876 sb.Append("[");
836 sb.Append(header); 877 sb.Append(header);
837 sb.Append("]"); 878 sb.Append("]");
838 std::unique_ptr<JSONValue> header_value = 879 std::unique_ptr<JSONValue> header_value =
839 ParseJSON(sb.ToString(), max_parse_depth); 880 ParseJSON(sb.ToString(), max_parse_depth);
840 return JSONArray::From(std::move(header_value)); 881 return JSONArray::From(std::move(header_value));
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 bool IsEnd(const String& input, unsigned index) { 1059 bool IsEnd(const String& input, unsigned index) {
1019 while (index < input.length()) { 1060 while (index < input.length()) {
1020 if (input[index] != ' ') 1061 if (input[index] != ' ')
1021 return false; 1062 return false;
1022 ++index; 1063 ++index;
1023 } 1064 }
1024 return true; 1065 return true;
1025 } 1066 }
1026 1067
1027 } // namespace blink 1068 } // namespace blink
OLDNEW
« 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