Chromium Code Reviews| 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 37a2afc1cf8f4bdacfd1fee67145ba951f01826e..6c63320df54ecca0c957694d33d0bdd81b9d42d0 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/json/JSONParser.h" |
| #include "platform/network/ResourceResponse.h" |
| #include "platform/weborigin/Suborigin.h" |
| #include "public/platform/WebString.h" |
| @@ -877,4 +878,16 @@ bool parseMultipartHeadersFromBody(const char* bytes, |
| return true; |
| } |
| +// See https://tools.ietf.org/html/draft-ietf-httpbis-jfv-01, Section 4. |
| +std::unique_ptr<JSONArray> parseJSONHeader(const String& header) { |
| + StringBuilder sb; |
| + sb.append("["); |
| + sb.append(header); |
| + sb.append("]"); |
| + std::unique_ptr<JSONValue> headerValue = parseJSON(sb.toString()); |
| + if (!headerValue) |
| + return std::unique_ptr<JSONArray>(nullptr); // Header is not valid JSON |
|
dcheng
2016/10/24 19:16:45
Nit: return nullptr works.
iclelland
2016/10/25 18:34:33
Nice, thanks. Done.
|
| + return JSONArray::cast(std::move(headerValue)); |
| +} |
| + |
| } // namespace blink |