| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
| 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
| 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 if (!isValidHTTPToken(name)) { | 1167 if (!isValidHTTPToken(name)) { |
| 1168 exceptionState.throwDOMException(SyntaxError, "'" + name + "' is not a v
alid HTTP header field name."); | 1168 exceptionState.throwDOMException(SyntaxError, "'" + name + "' is not a v
alid HTTP header field name."); |
| 1169 return; | 1169 return; |
| 1170 } | 1170 } |
| 1171 | 1171 |
| 1172 if (!isValidHTTPHeaderValue(value)) { | 1172 if (!isValidHTTPHeaderValue(value)) { |
| 1173 exceptionState.throwDOMException(SyntaxError, "'" + value + "' is not a
valid HTTP header field value."); | 1173 exceptionState.throwDOMException(SyntaxError, "'" + value + "' is not a
valid HTTP header field value."); |
| 1174 return; | 1174 return; |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 // Show deprecation warnings and count occurrences of such deprecated header
values. | |
| 1178 if (!value.isEmpty() && !isValidHTTPFieldContentRFC7230(value)) | |
| 1179 UseCounter::countDeprecation(executionContext(), UseCounter::HeaderValue
NotMatchingRFC7230); | |
| 1180 | |
| 1181 // No script (privileged or not) can set unsafe headers. | 1177 // No script (privileged or not) can set unsafe headers. |
| 1182 if (FetchUtils::isForbiddenHeaderName(name)) { | 1178 if (FetchUtils::isForbiddenHeaderName(name)) { |
| 1183 logConsoleError(executionContext(), "Refused to set unsafe header \"" +
name + "\""); | 1179 logConsoleError(executionContext(), "Refused to set unsafe header \"" +
name + "\""); |
| 1184 return; | 1180 return; |
| 1185 } | 1181 } |
| 1186 | 1182 |
| 1187 setRequestHeaderInternal(name, value); | 1183 setRequestHeaderInternal(name, value); |
| 1188 } | 1184 } |
| 1189 | 1185 |
| 1190 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At
omicString& value) | 1186 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const At
omicString& value) |
| 1191 { | 1187 { |
| 1188 // We show deprecation warnings if |value| is still invalid header value |
| 1189 // after normalization (i.e. contains invalid octets). |
| 1190 String normalizedValue = FetchUtils::normalizeHeaderValue(value); |
| 1191 if (!normalizedValue.isEmpty() && !isValidHTTPFieldContentRFC7230(normalized
Value)) |
| 1192 UseCounter::countDeprecation(executionContext(), UseCounter::HeaderValue
NotMatchingRFC7230); |
| 1193 |
| 1192 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); | 1194 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); |
| 1193 if (!result.isNewEntry) | 1195 if (result.isNewEntry) |
| 1194 result.storedValue->value = result.storedValue->value + ", " + value; | 1196 return; |
| 1197 |
| 1198 AtomicString newValue = result.storedValue->value + ", " + value; |
| 1199 |
| 1200 // We show deprecation warnings if this call to setRequestHeader() is |
| 1201 // affected by header value normalization. |
| 1202 // Without normalization at XHR level here, the actual header value |
| 1203 // sent to the network is |newValue| with leading/trailing whitespaces |
| 1204 // stripped (i.e. |normalizeHeaderValue(newValue)|). |
| 1205 // With normalization at XHR level here as the spec requires, the |
| 1206 // actual header value sent to the network is |normalizedNewValue|. |
| 1207 // If these two are different, introducing normalization here affects |
| 1208 // the header value sent to the network so we show warnings. |
| 1209 String normalizedNewValue = FetchUtils::normalizeHeaderValue(result.storedVa
lue->value) + ", " + FetchUtils::normalizeHeaderValue(value); |
| 1210 if (FetchUtils::normalizeHeaderValue(newValue) != normalizedNewValue) |
| 1211 UseCounter::countDeprecation(executionContext(), UseCounter::XHRSetReque
stHeaderAffectedByNormalization); |
| 1212 |
| 1213 result.storedValue->value = newValue; |
| 1195 } | 1214 } |
| 1196 | 1215 |
| 1197 const AtomicString& XMLHttpRequest::getRequestHeader(const AtomicString& name) c
onst | 1216 const AtomicString& XMLHttpRequest::getRequestHeader(const AtomicString& name) c
onst |
| 1198 { | 1217 { |
| 1199 return m_requestHeaders.get(name); | 1218 return m_requestHeaders.get(name); |
| 1200 } | 1219 } |
| 1201 | 1220 |
| 1202 String XMLHttpRequest::getAllResponseHeaders() const | 1221 String XMLHttpRequest::getAllResponseHeaders() const |
| 1203 { | 1222 { |
| 1204 if (m_state < HEADERS_RECEIVED || m_error) | 1223 if (m_state < HEADERS_RECEIVED || m_error) |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 visitor->trace(m_responseDocumentParser); | 1707 visitor->trace(m_responseDocumentParser); |
| 1689 visitor->trace(m_progressEventThrottle); | 1708 visitor->trace(m_progressEventThrottle); |
| 1690 visitor->trace(m_upload); | 1709 visitor->trace(m_upload); |
| 1691 visitor->trace(m_blobLoader); | 1710 visitor->trace(m_blobLoader); |
| 1692 XMLHttpRequestEventTarget::trace(visitor); | 1711 XMLHttpRequestEventTarget::trace(visitor); |
| 1693 DocumentParserClient::trace(visitor); | 1712 DocumentParserClient::trace(visitor); |
| 1694 ActiveDOMObject::trace(visitor); | 1713 ActiveDOMObject::trace(visitor); |
| 1695 } | 1714 } |
| 1696 | 1715 |
| 1697 } // namespace blink | 1716 } // namespace blink |
| OLD | NEW |