Diff
Modified: trunk/Source/WebCore/ChangeLog (169942 => 169943)
--- trunk/Source/WebCore/ChangeLog 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/ChangeLog 2014-06-13 19:35:05 UTC (rev 169943)
@@ -1,5 +1,22 @@
2014-06-13 Anders Carlsson <ander...@apple.com>
+ Add a HTTPHeaderMap::set overload that takes a HTTPHeaderName
+ https://bugs.webkit.org/show_bug.cgi?id=133874
+
+ Reviewed by Tim Horton.
+
+ * platform/network/HTTPHeaderMap.cpp:
+ (WebCore::HTTPHeaderMap::set):
+ * platform/network/HTTPHeaderMap.h:
+ * platform/network/cf/ResourceRequestCFNet.cpp:
+ (WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
+ * platform/network/mac/ResourceRequestMac.mm:
+ (WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::send):
+
+2014-06-13 Anders Carlsson <ander...@apple.com>
+
Add a HTTPHeaderMap::find overload that takes a HTTPHeaderName
https://bugs.webkit.org/show_bug.cgi?id=133872
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp (169942 => 169943)
--- trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderMap.cpp 2014-06-13 19:35:05 UTC (rev 169943)
@@ -99,6 +99,11 @@
}
};
+void HTTPHeaderMap::set(HTTPHeaderName name, const String& value)
+{
+ m_headers.set(httpHeaderNameString(name).toStringWithoutCopying(), value);
+}
+
bool HTTPHeaderMap::contains(HTTPHeaderName name) const
{
return m_headers.contains(httpHeaderNameString(name).toStringWithoutCopying());
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderMap.h (169942 => 169943)
--- trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2014-06-13 19:35:05 UTC (rev 169943)
@@ -63,12 +63,15 @@
void set(const AtomicString& name, const String& value);
void add(const AtomicString& name, const String& value);
+ void set(HTTPHeaderName, const String& value);
bool contains(HTTPHeaderName) const;
String get(const char*) const;
const_iterator find(HTTPHeaderName) const;
bool remove(HTTPHeaderName);
// Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead.
+ template<size_t length> void set(const char (&)[length], const String&) = delete;
+ template<size_t length> void add(const char (&)[length], const String&) = delete;
template<size_t length> bool contains(const char (&)[length]) = delete;
template<size_t length> const_iterator find(const char(&)[length]) = delete;
template<size_t length> bool remove(const char (&)[length]) = delete;
Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp (169942 => 169943)
--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp 2014-06-13 19:35:05 UTC (rev 169943)
@@ -26,6 +26,7 @@
#include "config.h"
#include "ResourceRequestCFNet.h"
+#include "HTTPHeaderNames.h"
#include "ResourceRequest.h"
#include <wtf/PassOwnPtr.h>
@@ -219,12 +220,11 @@
if (RetainPtr<CFReadStreamRef> bodyStream = adoptCF(CFURLRequestCopyHTTPRequestBodyStream(cfRequest))) {
// For streams, provide a Content-Length to avoid using chunked encoding, and to get accurate total length in callbacks.
- RetainPtr<CFStringRef> lengthString = adoptCF(static_cast<CFStringRef>(CFReadStreamCopyProperty(bodyStream.get(), formDataStreamLengthPropertyName())));
- if (lengthString) {
+ if (RetainPtr<CFStringRef> lengthString = adoptCF(static_cast<CFStringRef>(CFReadStreamCopyProperty(bodyStream.get(), formDataStreamLengthPropertyName())))) {
CFURLRequestSetHTTPHeaderFieldValue(cfRequest, CFSTR("Content-Length"), lengthString.get());
// Since resource request is already marked updated, we need to keep it up to date too.
ASSERT(m_resourceRequestUpdated);
- m_httpHeaderFields.set("Content-Length", lengthString.get());
+ m_httpHeaderFields.set(HTTPHeaderName::ContentLength, lengthString.get());
}
}
Modified: trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm (169942 => 169943)
--- trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/platform/network/mac/ResourceRequestMac.mm 2014-06-13 19:35:05 UTC (rev 169943)
@@ -27,6 +27,7 @@
#import "ResourceRequest.h"
#import "FormDataStreamMac.h"
+#import "HTTPHeaderNames.h"
#import "ResourceRequestCFNet.h"
#import "RuntimeApplicationChecks.h"
#import "WebCoreSystemInterface.h"
@@ -235,7 +236,7 @@
[nsRequest setValue:lengthString forHTTPHeaderField:@"Content-Length"];
// Since resource request is already marked updated, we need to keep it up to date too.
ASSERT(m_resourceRequestUpdated);
- m_httpHeaderFields.set("Content-Length", lengthString);
+ m_httpHeaderFields.set(HTTPHeaderName::ContentLength, lengthString);
}
}
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (169942 => 169943)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-06-13 18:56:58 UTC (rev 169942)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2014-06-13 19:35:05 UTC (rev 169943)
@@ -33,6 +33,7 @@
#include "ExceptionCode.h"
#include "File.h"
#include "HTMLDocument.h"
+#include "HTTPHeaderNames.h"
#include "HTTPParsers.h"
#include "InspectorInstrumentation.h"
#include "JSDOMBinding.h"
@@ -632,7 +633,7 @@
setRequestHeaderInternal("Content-Type", "application/xml");
} else {
replaceCharsetInMediaType(contentType, "UTF-8");
- m_requestHeaders.set("Content-Type", contentType);
+ m_requestHeaders.set(HTTPHeaderName::ContentType, contentType);
}
m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, EntitiesForUnencodables));