OLD | NEW |
---|---|
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 16 matching lines...) Expand all Loading... | |
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
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_response_headers.h" | 35 #include "net/http/http_response_headers.h" |
36 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
37 #include "platform/json/JSONParser.h" | |
37 #include "platform/network/ResourceResponse.h" | 38 #include "platform/network/ResourceResponse.h" |
38 #include "platform/weborigin/Suborigin.h" | 39 #include "platform/weborigin/Suborigin.h" |
39 #include "public/platform/WebString.h" | 40 #include "public/platform/WebString.h" |
40 #include "wtf/DateMath.h" | 41 #include "wtf/DateMath.h" |
41 #include "wtf/MathExtras.h" | 42 #include "wtf/MathExtras.h" |
42 #include "wtf/text/CString.h" | 43 #include "wtf/text/CString.h" |
43 #include "wtf/text/CharacterNames.h" | 44 #include "wtf/text/CharacterNames.h" |
44 #include "wtf/text/ParsingUtilities.h" | 45 #include "wtf/text/ParsingUtilities.h" |
45 #include "wtf/text/StringBuilder.h" | 46 #include "wtf/text/StringBuilder.h" |
46 #include "wtf/text/StringUTF8Adaptor.h" | 47 #include "wtf/text/StringUTF8Adaptor.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 | 871 |
871 response->clearHTTPHeaderField(header); | 872 response->clearHTTPHeaderField(header); |
872 while (responseHeaders->EnumerateHeader(&iterator, headerStringPiece, | 873 while (responseHeaders->EnumerateHeader(&iterator, headerStringPiece, |
873 &value)) { | 874 &value)) { |
874 response->addHTTPHeaderField(header, WebString::fromLatin1(value)); | 875 response->addHTTPHeaderField(header, WebString::fromLatin1(value)); |
875 } | 876 } |
876 } | 877 } |
877 return true; | 878 return true; |
878 } | 879 } |
879 | 880 |
881 // See https://tools.ietf.org/html/draft-ietf-httpbis-jfv-01, Section 4. | |
882 std::unique_ptr<JSONArray> parseJSONHeader(const String& header) { | |
883 StringBuilder sb; | |
884 sb.append("["); | |
885 sb.append(header); | |
886 sb.append("]"); | |
887 std::unique_ptr<JSONValue> headerValue = parseJSON(sb.toString()); | |
888 if (!headerValue) | |
dcheng
2016/11/03 05:54:43
Nit: this early return isn't necessary (JSONArray:
iclelland
2016/11/03 14:59:20
Done, thanks.
| |
889 return nullptr; // Header is not valid JSON | |
890 return JSONArray::cast(std::move(headerValue)); | |
891 } | |
892 | |
880 } // namespace blink | 893 } // namespace blink |
OLD | NEW |