OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "FetchHeaderList.h" | 6 #include "FetchHeaderList.h" |
7 | 7 |
8 #include "core/fetch/CrossOriginAccessControl.h" | 8 #include "core/fetch/CrossOriginAccessControl.h" |
9 #include "core/xml/XMLHttpRequest.h" | 9 #include "core/xml/XMLHttpRequest.h" |
10 #include "platform/network/HTTPParsers.h" | 10 #include "platform/network/HTTPParsers.h" |
11 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
12 | 12 |
13 namespace WebCore { | 13 namespace WebCore { |
14 | 14 |
15 PassRefPtr<FetchHeaderList> FetchHeaderList::create() | 15 PassRefPtr<FetchHeaderList> FetchHeaderList::create() |
16 { | 16 { |
17 return adoptRef(new FetchHeaderList()); | 17 return adoptRef(new FetchHeaderList()); |
18 } | 18 } |
19 | 19 |
| 20 PassRefPtr<FetchHeaderList> FetchHeaderList::createCopy() |
| 21 { |
| 22 RefPtr<FetchHeaderList> list(create()); |
| 23 for (size_t i = 0; i < m_headerList.size(); ++i) { |
| 24 list->append(m_headerList[i]->first, m_headerList[i]->second); |
| 25 } |
| 26 return list.release(); |
| 27 } |
| 28 |
20 FetchHeaderList::FetchHeaderList() | 29 FetchHeaderList::FetchHeaderList() |
21 { | 30 { |
22 } | 31 } |
23 | 32 |
24 FetchHeaderList::~FetchHeaderList() | 33 FetchHeaderList::~FetchHeaderList() |
25 { | 34 { |
26 } | 35 } |
27 | 36 |
28 void FetchHeaderList::append(const String& name, const String& value) | 37 void FetchHeaderList::append(const String& name, const String& value) |
29 { | 38 { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 bool FetchHeaderList::isForbiddenHeaderName(const String& name) | 153 bool FetchHeaderList::isForbiddenHeaderName(const String& name) |
145 { | 154 { |
146 // "A forbidden header name is a header names that is one of: | 155 // "A forbidden header name is a header names that is one of: |
147 // `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`, | 156 // `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`, |
148 // `Access-Control-Request-Method`, `Connection`, | 157 // `Access-Control-Request-Method`, `Connection`, |
149 // `Content-Length, Cookie`, `Cookie2`, `Date`, `DNT`, `Expect`, `Host`, | 158 // `Content-Length, Cookie`, `Cookie2`, `Date`, `DNT`, `Expect`, `Host`, |
150 // `Keep-Alive`, `Origin`, `Referer`, `TE`, `Trailer`, | 159 // `Keep-Alive`, `Origin`, `Referer`, `TE`, `Trailer`, |
151 // `Transfer-Encoding`, `Upgrade`, `User-Agent`, `Via` | 160 // `Transfer-Encoding`, `Upgrade`, `User-Agent`, `Via` |
152 // or starts with `Proxy-` or `Sec-` (including when it is just `Proxy-` or | 161 // or starts with `Proxy-` or `Sec-` (including when it is just `Proxy-` or |
153 // `Sec-`)." | 162 // `Sec-`)." |
154 return !XMLHttpRequest::isAllowedHTTPHeader(name); | 163 return !XMLHttpRequest::isAllowedHTTPHeader(name) || equalIgnoringCase(name,
"DNT"); |
155 } | 164 } |
156 | 165 |
157 bool FetchHeaderList::isForbiddenResponseHeaderName(const String& name) | 166 bool FetchHeaderList::isForbiddenResponseHeaderName(const String& name) |
158 { | 167 { |
159 // "A forbidden response header name is a header name that is one of: | 168 // "A forbidden response header name is a header name that is one of: |
160 // `Set-Cookie`, `Set-Cookie2`" | 169 // `Set-Cookie`, `Set-Cookie2`" |
161 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); | 170 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); |
162 } | 171 } |
163 | 172 |
164 } // namespace WebCore | 173 } // namespace WebCore |
OLD | NEW |