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

Side by Side Diff: third_party/WebKit/Source/platform/network/HTTPParsers.cpp

Issue 2568343002: GetMimeTypeAndCharset at once (Closed)
Patch Set: Created 4 years 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 | « no previous file | 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 // Eat headers and prepend a status line as is required by 868 // Eat headers and prepend a status line as is required by
869 // HttpResponseHeaders. 869 // HttpResponseHeaders.
870 std::string headers("HTTP/1.1 200 OK\r\n"); 870 std::string headers("HTTP/1.1 200 OK\r\n");
871 headers.append(bytes, headersEndPos); 871 headers.append(bytes, headersEndPos);
872 872
873 scoped_refptr<net::HttpResponseHeaders> responseHeaders = 873 scoped_refptr<net::HttpResponseHeaders> responseHeaders =
874 new net::HttpResponseHeaders( 874 new net::HttpResponseHeaders(
875 net::HttpUtil::AssembleRawHeaders(headers.data(), headers.length())); 875 net::HttpUtil::AssembleRawHeaders(headers.data(), headers.length()));
876 876
877 std::string mimeType; 877 std::string mimeType, charset;
878 responseHeaders->GetMimeType(&mimeType); 878 responseHeaders->GetMimeTypeAndCharset(&mimeType, &charset);
879 response->setMimeType(WebString::fromUTF8(mimeType)); 879 response->setMimeType(WebString::fromUTF8(mimeType));
880
881 std::string charset;
882 responseHeaders->GetCharset(&charset);
883 response->setTextEncodingName(WebString::fromUTF8(charset)); 880 response->setTextEncodingName(WebString::fromUTF8(charset));
884 881
885 // Copy headers listed in replaceHeaders to the response. 882 // Copy headers listed in replaceHeaders to the response.
886 for (const AtomicString& header : replaceHeaders()) { 883 for (const AtomicString& header : replaceHeaders()) {
887 std::string value; 884 std::string value;
888 StringUTF8Adaptor adaptor(header); 885 StringUTF8Adaptor adaptor(header);
889 base::StringPiece headerStringPiece(adaptor.asStringPiece()); 886 base::StringPiece headerStringPiece(adaptor.asStringPiece());
890 size_t iterator = 0; 887 size_t iterator = 0;
891 888
892 response->clearHTTPHeaderField(header); 889 response->clearHTTPHeaderField(header);
(...skipping 11 matching lines...) Expand all
904 StringBuilder sb; 901 StringBuilder sb;
905 sb.append("["); 902 sb.append("[");
906 sb.append(header); 903 sb.append(header);
907 sb.append("]"); 904 sb.append("]");
908 std::unique_ptr<JSONValue> headerValue = 905 std::unique_ptr<JSONValue> headerValue =
909 parseJSON(sb.toString(), maxParseDepth); 906 parseJSON(sb.toString(), maxParseDepth);
910 return JSONArray::from(std::move(headerValue)); 907 return JSONArray::from(std::move(headerValue));
911 } 908 }
912 909
913 } // namespace blink 910 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698