Modified: trunk/Source/WebCore/ChangeLog (192679 => 192680)
--- trunk/Source/WebCore/ChangeLog 2015-11-20 09:06:05 UTC (rev 192679)
+++ trunk/Source/WebCore/ChangeLog 2015-11-20 09:25:56 UTC (rev 192680)
@@ -1,3 +1,21 @@
+2015-11-20 Youenn Fablet <youenn.fab...@crf.canon.fr>
+
+ Use HTTPHeaderName as much as possible in XMLHttpRequest
+ https://bugs.webkit.org/show_bug.cgi?id=151438
+
+ Reviewed by Darin Adler.
+
+ Removing XMLHttpRequest::setRequestHeaderInternal and XMLHttpRequest::getRequestHeader.
+ Using directly HTTPHeaderMap.add, HTTPHeaderMap.set and HTTPHeaderMap.get.
+
+ No change in behavior.
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::send):
+ (WebCore::XMLHttpRequest::setRequestHeader):
+ (WebCore::XMLHttpRequest::getAllResponseHeaders):
+ * xml/XMLHttpRequest.h:
+
2015-11-20 Eric Carlson <eric.carl...@apple.com>
MediaStream: Fix mock video source crash
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (192679 => 192680)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2015-11-20 09:06:05 UTC (rev 192679)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2015-11-20 09:25:56 UTC (rev 192680)
@@ -595,11 +595,11 @@
if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) {
#if ENABLE(DASHBOARD_SUPPORT)
if (usesDashboardBackwardCompatibilityMode())
- setRequestHeaderInternal("Content-Type", "application/x-www-form-urlencoded");
+ m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("application/x-www-form-urlencoded"));
else
#endif
// FIXME: this should include the charset used for encoding.
- setRequestHeaderInternal("Content-Type", document->isHTMLDocument() ? "text/html;charset=UTF-8":"application/xml;charset=UTF-8");
+ m_requestHeaders.set(HTTPHeaderName::ContentType, document->isHTMLDocument() ? ASCIILiteral("text/html;charset=UTF-8") : ASCIILiteral("application/xml;charset=UTF-8"));
}
// FIXME: According to XMLHttpRequest Level 2, this should use the Document.innerHTML algorithm
@@ -620,14 +620,14 @@
return;
if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
- String contentType = getRequestHeader("Content-Type");
+ String contentType = m_requestHeaders.get(HTTPHeaderName::ContentType);
if (contentType.isNull()) {
#if ENABLE(DASHBOARD_SUPPORT)
if (usesDashboardBackwardCompatibilityMode())
- setRequestHeaderInternal("Content-Type", "application/x-www-form-urlencoded");
+ m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("application/x-www-form-urlencoded"));
else
#endif
- setRequestHeaderInternal("Content-Type", "text/plain;charset=UTF-8");
+ m_requestHeaders.set(HTTPHeaderName::ContentType, ASCIILiteral("text/plain;charset=UTF-8"));
} else {
replaceCharsetInMediaType(contentType, "UTF-8");
m_requestHeaders.set(HTTPHeaderName::ContentType, contentType);
@@ -650,10 +650,10 @@
if (!m_requestHeaders.contains(HTTPHeaderName::ContentType)) {
const String& blobType = body->type();
if (!blobType.isEmpty() && isValidContentType(blobType))
- setRequestHeaderInternal("Content-Type", blobType);
+ m_requestHeaders.set(HTTPHeaderName::ContentType, blobType);
else {
// From FileAPI spec, whenever media type cannot be determined, empty string must be returned.
- setRequestHeaderInternal("Content-Type", "");
+ m_requestHeaders.set(HTTPHeaderName::ContentType, emptyString());
}
}
@@ -675,7 +675,7 @@
m_requestEntityBody->generateFiles(document());
if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
- setRequestHeaderInternal("Content-Type", makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
+ m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
}
createRequest(ec);
@@ -955,19 +955,9 @@
return;
}
- setRequestHeaderInternal(name, normalizedValue);
+ m_requestHeaders.add(name, normalizedValue);
}
-void XMLHttpRequest::setRequestHeaderInternal(const String& name, const String& value)
-{
- m_requestHeaders.add(name, value);
-}
-
-String XMLHttpRequest::getRequestHeader(const String& name) const
-{
- return m_requestHeaders.get(name);
-}
-
String XMLHttpRequest::getAllResponseHeaders() const
{
if (m_state < HEADERS_RECEIVED || m_error)
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (192679 => 192680)
--- trunk/Source/WebCore/xml/XMLHttpRequest.h 2015-11-20 09:06:05 UTC (rev 192679)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h 2015-11-20 09:25:56 UTC (rev 192680)
@@ -176,9 +176,6 @@
bool initSend(ExceptionCode&);
void sendBytesData(const void*, size_t, ExceptionCode&);
- String getRequestHeader(const String& name) const;
- void setRequestHeaderInternal(const String& name, const String& value);
-
void changeState(State newState);
void callReadyStateChangeListener();
void dropProtection();