| 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 return list.release(); |
| 26 } |
| 27 |
| 20 FetchHeaderList::FetchHeaderList() | 28 FetchHeaderList::FetchHeaderList() |
| 21 { | 29 { |
| 22 } | 30 } |
| 23 | 31 |
| 24 FetchHeaderList::~FetchHeaderList() | 32 FetchHeaderList::~FetchHeaderList() |
| 25 { | 33 { |
| 26 } | 34 } |
| 27 | 35 |
| 28 void FetchHeaderList::append(const String& name, const String& value) | 36 void FetchHeaderList::append(const String& name, const String& value) |
| 29 { | 37 { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool FetchHeaderList::isForbiddenHeaderName(const String& name) | 160 bool FetchHeaderList::isForbiddenHeaderName(const String& name) |
| 153 { | 161 { |
| 154 // "A forbidden header name is a header names that is one of: | 162 // "A forbidden header name is a header names that is one of: |
| 155 // `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`, | 163 // `Accept-Charset`, `Accept-Encoding`, `Access-Control-Request-Headers`, |
| 156 // `Access-Control-Request-Method`, `Connection`, | 164 // `Access-Control-Request-Method`, `Connection`, |
| 157 // `Content-Length, Cookie`, `Cookie2`, `Date`, `DNT`, `Expect`, `Host`, | 165 // `Content-Length, Cookie`, `Cookie2`, `Date`, `DNT`, `Expect`, `Host`, |
| 158 // `Keep-Alive`, `Origin`, `Referer`, `TE`, `Trailer`, | 166 // `Keep-Alive`, `Origin`, `Referer`, `TE`, `Trailer`, |
| 159 // `Transfer-Encoding`, `Upgrade`, `User-Agent`, `Via` | 167 // `Transfer-Encoding`, `Upgrade`, `User-Agent`, `Via` |
| 160 // or starts with `Proxy-` or `Sec-` (including when it is just `Proxy-` or | 168 // or starts with `Proxy-` or `Sec-` (including when it is just `Proxy-` or |
| 161 // `Sec-`)." | 169 // `Sec-`)." |
| 162 return !XMLHttpRequest::isAllowedHTTPHeader(name); | 170 return !XMLHttpRequest::isAllowedHTTPHeader(name) || equalIgnoringCase(name,
"DNT"); |
| 163 } | 171 } |
| 164 | 172 |
| 165 bool FetchHeaderList::isForbiddenResponseHeaderName(const String& name) | 173 bool FetchHeaderList::isForbiddenResponseHeaderName(const String& name) |
| 166 { | 174 { |
| 167 // "A forbidden response header name is a header name that is one of: | 175 // "A forbidden response header name is a header name that is one of: |
| 168 // `Set-Cookie`, `Set-Cookie2`" | 176 // `Set-Cookie`, `Set-Cookie2`" |
| 169 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); | 177 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set
-cookie2"); |
| 170 } | 178 } |
| 171 | 179 |
| 172 } // namespace WebCore | 180 } // namespace WebCore |
| OLD | NEW |