LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2006 04:25:02 +0000 (04:25 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Oct 2006 04:25:02 +0000 (04:25 +0000)
        Reviewed by Oliver.

        - re-enable testing of HEAD methods, now that bugs relating to these are fixed

        * http/tests/xmlhttprequest/methods-async-expected.txt:
        * http/tests/xmlhttprequest/methods-async.html:
        * http/tests/xmlhttprequest/methods-expected.txt:
        * http/tests/xmlhttprequest/methods.html:

WebCore:

        Reviewed by Oliver.

        - more ResourceLoader cleanup
            - moved HTTPHeaderMap out of ResourceRequest class, so ResourceResponse will be able to use it too
            - took out attempts to suppress setting of "HEAD" and "GET" methods, since underlying bugs are now fixed

        * loader/LoaderFunctions.h:
        * loader/mac/LoaderFunctionsMac.mm:
        (WebCore::ServeSynchronousRequest):
        * loader/mac/WebSubresourceLoader.mm:
        (-[WebCoreSubresourceHandle initWithLoader:]):
        * platform/network/HTTPHeaderMap.h: Added.
        * platform/network/ResourceLoader.cpp:
        (WebCore::ResourceLoader::requestHeaders):
        * platform/network/ResourceLoader.h:
        * platform/network/ResourceRequest.h:
        * platform/network/cf/ResourceLoaderCFNet.cpp:
        (WebCore::addHeadersFromHashMap):
        * xml/xmlhttprequest.cpp:
        (WebCore::XMLHttpRequest::send):
        * xml/xmlhttprequest.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/methods-async-expected.txt
LayoutTests/http/tests/xmlhttprequest/methods-async.html
LayoutTests/http/tests/xmlhttprequest/methods-expected.txt
LayoutTests/http/tests/xmlhttprequest/methods.html
WebCore/ChangeLog
WebCore/loader/LoaderFunctions.h
WebCore/loader/mac/LoaderFunctionsMac.mm
WebCore/loader/mac/WebSubresourceLoader.mm
WebCore/platform/network/HTTPHeaderMap.h [new file with mode: 0644]
WebCore/platform/network/ResourceLoader.cpp
WebCore/platform/network/ResourceLoader.h
WebCore/platform/network/ResourceRequest.h
WebCore/platform/network/cf/ResourceLoaderCFNet.cpp
WebCore/xml/xmlhttprequest.cpp
WebCore/xml/xmlhttprequest.h

index 6b7928761229f932a7a84335b39cbd9bd4379f10..ff8fb0290070372b71b59402155395863e4fb020 100644 (file)
@@ -1,3 +1,14 @@
+2006-10-24  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+
+        - re-enable testing of HEAD methods, now that bugs relating to these are fixed
+
+        * http/tests/xmlhttprequest/methods-async-expected.txt:
+        * http/tests/xmlhttprequest/methods-async.html:
+        * http/tests/xmlhttprequest/methods-expected.txt:
+        * http/tests/xmlhttprequest/methods.html:
+
 2006-10-24  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
index cd8e48f580b0bd6e7c998d56e9b2222d00a35420..55b37c987a8ef900ab3a2f747feee328410381f3 100644 (file)
@@ -12,6 +12,9 @@ PUT("123"): PUT(3 bytes), Content-Type: application/xml
 DELETE(""): DELETE(0 bytes), Content-Type: application/xml
 DELETE(null): DELETE(0 bytes), Content-Type: undefined
 DELETE("123"): DELETE(3 bytes), Content-Type: application/xml
+HEAD(""): HEAD(0 bytes), Content-Type: undefined
+HEAD(null): HEAD(0 bytes), Content-Type: undefined
+HEAD("123"): HEAD(0 bytes), Content-Type: undefined
 WKFOOBAR(""): WKFOOBAR(0 bytes), Content-Type: application/xml
 WKFOOBAR(null): WKFOOBAR(0 bytes), Content-Type: undefined
 WKFOOBAR("123"): WKFOOBAR(3 bytes), Content-Type: application/xml
index 3a1309f3bf95b2e4673f1f1caedd967a40ae3ed8..3a01570937b1eea177d63539e06e6ffc7a6b25ea 100644 (file)
@@ -82,7 +82,7 @@ GET and POST should not be the only HTTP methods implemented in XMLHttpRequest.<
              req.open("DELETE", "methods.cgi", true);
              req.send(null);
            } else if (asyncStep == 11) {
-             asyncStep = 15;// 12;
+             asyncStep = 12;
              log('DELETE(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
              req.open("DELETE", "methods.cgi", true);
              req.send("123");
@@ -103,8 +103,7 @@ GET and POST should not be the only HTTP methods implemented in XMLHttpRequest.<
              req.send("123");
            } else if (asyncStep == 15) {
              asyncStep = 16;
-             log('DELETE("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
-             //log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+             log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
              req.open("WKFOOBAR", "methods.cgi", true);
              req.send("");
            } else if (asyncStep == 16) {
index cd8e48f580b0bd6e7c998d56e9b2222d00a35420..55b37c987a8ef900ab3a2f747feee328410381f3 100644 (file)
@@ -12,6 +12,9 @@ PUT("123"): PUT(3 bytes), Content-Type: application/xml
 DELETE(""): DELETE(0 bytes), Content-Type: application/xml
 DELETE(null): DELETE(0 bytes), Content-Type: undefined
 DELETE("123"): DELETE(3 bytes), Content-Type: application/xml
+HEAD(""): HEAD(0 bytes), Content-Type: undefined
+HEAD(null): HEAD(0 bytes), Content-Type: undefined
+HEAD("123"): HEAD(0 bytes), Content-Type: undefined
 WKFOOBAR(""): WKFOOBAR(0 bytes), Content-Type: application/xml
 WKFOOBAR(null): WKFOOBAR(0 bytes), Content-Type: undefined
 WKFOOBAR("123"): WKFOOBAR(3 bytes), Content-Type: application/xml
index ef19f784a58d1caf217a6a55440247f16006a466..d3e1d0c4dc23738fb7e1fe349b6f1bcd1c581b8a 100644 (file)
@@ -65,7 +65,7 @@ GET and POST should not be the only HTTP methods implemented in XMLHttpRequest.<
     req.open("DELETE", "methods.cgi", false);
     req.send("123");
     log('DELETE("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
-/*
+
     req.open("HEAD", "methods.cgi", false);
     req.send("");
     log('HEAD(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
@@ -77,7 +77,7 @@ GET and POST should not be the only HTTP methods implemented in XMLHttpRequest.<
     req.open("HEAD", "methods.cgi", false);
     req.send("123");
     log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
-*/
+
     req.open("WKFOOBAR", "methods.cgi", false);
     req.send("");
     log('WKFOOBAR(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
index 91fd01fce8f3b3c7bbe450e83b02f725682c2550..b7d7ee92ae817ef59d04de1d974ac8a9bdd24df8 100644 (file)
@@ -1,3 +1,27 @@
+2006-10-24  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+
+        - more ResourceLoader cleanup
+            - moved HTTPHeaderMap out of ResourceRequest class, so ResourceResponse will be able to use it too
+            - took out attempts to suppress setting of "HEAD" and "GET" methods, since underlying bugs are now fixed
+        
+        * loader/LoaderFunctions.h:
+        * loader/mac/LoaderFunctionsMac.mm:
+        (WebCore::ServeSynchronousRequest):
+        * loader/mac/WebSubresourceLoader.mm:
+        (-[WebCoreSubresourceHandle initWithLoader:]):
+        * platform/network/HTTPHeaderMap.h: Added.
+        * platform/network/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::requestHeaders):
+        * platform/network/ResourceLoader.h:
+        * platform/network/ResourceRequest.h:
+        * platform/network/cf/ResourceLoaderCFNet.cpp:
+        (WebCore::addHeadersFromHashMap):
+        * xml/xmlhttprequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+        * xml/xmlhttprequest.h:
+
 2006-10-24  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
index 8ff919a0ecc677a990d4a8f9b167f55f5a3a0142..6f190160b9c8f65e3873a9942223de81015c38e6 100644 (file)
 #include <wtf/HashMap.h>
 #include "PlatformString.h"
 #include "ResourceLoaderClient.h"  // Defines PlatformResponse
-#include "ResourceRequest.h"
+#include "HTTPHeaderMap.h"
 
 #ifdef __OBJC__
 @class NSDictionary;
 @class NSString;
 
 @interface NSDictionary (WebCore_Extras)
-+ (id)_webcore_dictionaryWithHeaderMap:(const WebCore::ResourceRequest::HTTPHeaderMap&)headerMap;
++ (id)_webcore_dictionaryWithHeaderMap:(const WebCore::HTTPHeaderMap&)headerMap;
 @end
 
 #else
index 6979f5eb12482923f5db9cfb95112282663aea2f..b56c0630c12ca462a664f0ce2f33cb6e7c9a90cc 100644 (file)
@@ -48,12 +48,12 @@ using namespace WebCore;
 
 @implementation NSDictionary (WebCore_Extras)
 
-+ (id)_webcore_dictionaryWithHeaderMap:(const ResourceRequest::HTTPHeaderMap&)headerMap
++ (id)_webcore_dictionaryWithHeaderMap:(const HTTPHeaderMap&)headerMap
 {
     NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
     
-    ResourceRequest::HTTPHeaderMap::const_iterator end = headerMap.end();
-    for (ResourceRequest::HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it)
+    HTTPHeaderMap::const_iterator end = headerMap.end();
+    for (HTTPHeaderMap::const_iterator it = headerMap.begin(); it != end; ++it)
         [headers setValue:it->second forKey:it->first];
     
     return [headers autorelease];
@@ -101,7 +101,7 @@ Vector<char> ServeSynchronousRequest(Loader *loader, DocLoader *docLoader, const
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     NSDictionary *headerDict = nil;
-    const ResourceRequest::HTTPHeaderMap& requestHeaders = request.httpHeaderFields();
+    const HTTPHeaderMap& requestHeaders = request.httpHeaderFields();
 
     if (!requestHeaders.isEmpty())
         headerDict = [NSDictionary _webcore_dictionaryWithHeaderMap:requestHeaders];
index 32c23385a15e328604417863862e742c948cc998..6e728619368517ec88e562594dbb6fd7bc8c50f8 100644 (file)
@@ -70,9 +70,7 @@ id <WebCoreResourceHandle> SubresourceLoader::create(Frame* frame, id <WebCoreRe
     if (fl->state() == WebFrameStateProvisional)
         return nil;
 
-    // setHTTPMethod is not called for GET requests to work around <rdar://4464032>.
-    if (![method isEqualToString:@"GET"])
-        [newRequest setHTTPMethod:method];
+    [newRequest setHTTPMethod:method];
 
     wkSupportsMultipartXMixedReplace(newRequest);
 
diff --git a/WebCore/platform/network/HTTPHeaderMap.h b/WebCore/platform/network/HTTPHeaderMap.h
new file mode 100644 (file)
index 0000000..8a9955a
--- /dev/null
@@ -0,0 +1,40 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef HTTPHeaderMap_H_
+#define HTTPHeaderMap_H_
+
+#include "PlatformString.h"
+#include "StringHash.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+    typedef HashMap<String, String, CaseInsensitiveHash<String> > HTTPHeaderMap;
+
+} // namespace WebCore
+
+#endif // HTTPHeaderMap_H_
index 6f7fd791c488774785238868e80c2d28fd2b9062..7b87981bb62dad7f02586efa918a6c162c96670e 100644 (file)
@@ -85,7 +85,7 @@ void ResourceLoader::kill()
     }
 }
 
-const ResourceRequest::HTTPHeaderMap& ResourceLoader::requestHeaders() const
+const HTTPHeaderMap& ResourceLoader::requestHeaders() const
 {
     return d->m_request.httpHeaderFields();
 }
index 70929ce90c8910a2145dd623c17d4505a45b63d2..888e32776786535457e672c6f4abb9e3b3062464 100644 (file)
@@ -110,7 +110,7 @@ public:
 
     void receivedResponse(PlatformResponse);
 
-    const ResourceRequest::HTTPHeaderMap& requestHeaders() const;
+    const HTTPHeaderMap& requestHeaders() const;
     const KURL& url() const;
     const String& method() const;
     const FormData& postData() const;
index 123641d4fec7c4186a1cc94fc1e541902dd8abbe..cefe7e74788594a7b97b7d670b49e96b5a729ecb 100644 (file)
@@ -30,9 +30,7 @@
 
 #include "FormData.h"
 #include "KURL.h"
-#include "PlatformString.h"
-#include "StringHash.h"
-#include <wtf/HashMap.h>
+#include "HTTPHeaderMap.h"
 
 namespace WebCore {
 
@@ -95,8 +93,6 @@ namespace WebCore {
         const String& httpMethod() const { return m_httpMethod; }
         void setHTTPMethod(const String& httpMethod) { m_httpMethod = httpMethod; }
         
-        typedef HashMap<String, String, CaseInsensitiveHash<String> > HTTPHeaderMap;
-
         const HTTPHeaderMap& httpHeaderFields() const { return m_httpHeaderFields; }
         String httpHeaderField(const String& name) const { return m_httpHeaderFields.get(name); }
         void setHTTPHeaderField(const String& name, const String& value) { m_httpHeaderFields.set(name, value); }
index 7c890783a108706e4abd9fcbf1da1f78330a98b6..b8705d636e650eb5750a272e5774e3cec942eadc 100644 (file)
@@ -150,14 +150,14 @@ void didReceiveChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challeng
     // Do nothing right now
 }
 
-void addHeadersFromHashMap(CFHTTPMessageRef request, const ResourceRequest::HTTPHeaderMap& requestHeaders) 
+void addHeadersFromHashMap(CFHTTPMessageRef request, const HTTPHeaderMap& requestHeaders) 
 {
     if (!requestHeaders.size())
         return;
 
     CFMutableDictionaryRef allHeaders = CFDictionaryCreateMutable(0, requestHeaders.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-    ResourceRequest::HTTPHeaderMap::const_iterator end = requestHeaders.end();
-    for (ResourceRequest::HTTPHeaderMap::const_iterator it = requestHeaders.begin(); it != end; ++it) {
+    HTTPHeaderMap::const_iterator end = requestHeaders.end();
+    for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(); it != end; ++it) {
         CFStringRef key = it->first.createCFString();
         CFStringRef value = it->second.createCFString();
         CFDictionaryAddValue(allHeaders, key, value);
index d84785f86af4ea8469176233b80bc3456fa38cc4..b7f92a2a082f9af450a956d21e1c2a7a6fe1df7f 100644 (file)
@@ -298,6 +298,7 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
     m_aborted = false;
 
     ResourceRequest request(m_url);
+    request.setHTTPMethod(m_method);
     
     if (!body.isNull() && m_method != "GET" && m_method != "HEAD" && (m_url.protocol().lower() == "http" || m_url.protocol().lower() == "https")) {
         String contentType = getRequestHeader("Content-Type");
@@ -317,13 +318,7 @@ void XMLHttpRequest::send(const String& body, ExceptionCode& ec)
             m_encoding = UTF8Encoding();
 
         request.setHTTPBody(m_encoding.encode(body.characters(), body.length()));
-    } else {
-        // FIXME: HEAD requests just crash; see <rdar://4460899> and the commented out tests in http/tests/xmlhttprequest/methods.html.
-        // FIXME: the radar is fixed, should conditionalize this
-        if (m_method == "HEAD")
-            m_method = "GET";
     }
-    request.setHTTPMethod(m_method);
 
     if (m_requestHeaders.size() > 0)
         request.addHTTPHeaderFields(m_requestHeaders);
index 98f319f05ae6e94598264ff4a9c3bcfc6f5593f0..77a852c11ea00faacabfe93db8e9cd8938dfbb2e 100644 (file)
@@ -27,7 +27,7 @@
 #include "KURL.h"
 #include "ResourceLoaderClient.h"
 #include "PlatformString.h"
-#include "ResourceRequest.h"
+#include "HTTPHeaderMap.h"
 #include "StringHash.h"
 
 namespace WebCore {
@@ -102,7 +102,7 @@ private:
     KURL m_url;
     DeprecatedString m_method;
     bool m_async;
-    ResourceRequest::HTTPHeaderMap m_requestHeaders;
+    HTTPHeaderMap m_requestHeaders;
 
     RefPtr<ResourceLoader> m_loader;