Reviewed by Maciej Stachowiak.
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Apr 2010 22:33:27 +0000 (22:33 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Apr 2010 22:33:27 +0000 (22:33 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=24572
        XMLHttpRequest.statusText returns always "OK" on Mac

        Covered by existing tests, which now pass.

        * WebCore.base.exp:
        * platform/mac/WebCoreSystemInterface.h:
        * platform/mac/WebCoreSystemInterface.mm:
        Added a WebKitSystemInterface method to fetch status line.

        * platform/network/HTTPParsers.cpp: (WebCore::extractReasonPhraseFromHTTPStatusLine):
        * platform/network/HTTPParsers.h:
        * platform/network/cf/ResourceResponseCFNet.cpp: (WebCore::ResourceResponse::platformLazyInit):
        Moved code for parsing status line to HTTPHeaders, as it's used for both Mac and CF now.

        * platform/network/mac/ResourceResponseMac.mm: (WebCore::ResourceResponse::platformLazyInit):
        Use the actual reason phrase when available, and "OK" otherwise. Synthesizing a reson when
        there isn't one is misleading, so we'll stick to our old broken behavior on Tiger, rather than
        introduce a new broken one.

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-tiger/http/tests/xmlhttprequest/web-apps/012-expected.txt [moved from LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/012-expected.txt with 100% similarity]
LayoutTests/platform/mac-tiger/http/tests/xmlhttprequest/web-apps/013-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-tiger/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt [moved from LayoutTests/platform/win/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt with 88% similarity]
LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/013-expected.txt [deleted file]
LayoutTests/platform/mac/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt [deleted file]
LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/012-expected.txt [deleted file]
LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/013-expected.txt [deleted file]
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/platform/mac/WebCoreSystemInterface.h
WebCore/platform/mac/WebCoreSystemInterface.mm
WebCore/platform/network/HTTPParsers.cpp
WebCore/platform/network/HTTPParsers.h
WebCore/platform/network/cf/ResourceResponseCFNet.cpp
WebCore/platform/network/mac/ResourceResponseMac.mm
WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebSystemInterface.m
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a
WebKitLibraries/libWebKitSystemInterfaceTiger.a

index c64216e..d182436 100644 (file)
@@ -1,3 +1,28 @@
+2010-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24572
+        XMLHttpRequest.statusText returns always "OK" on Mac
+
+        We only need custom results on Tiger now.
+
+        * platform/mac-tiger/http/tests/xmlhttprequest: Added.
+        * platform/mac-tiger/http/tests/xmlhttprequest/web-apps: Added.
+        * platform/mac-tiger/http/tests/xmlhttprequest/web-apps/012-expected.txt: Copied from LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/012-expected.txt.
+        * platform/mac-tiger/http/tests/xmlhttprequest/web-apps/013-expected.txt: Copied from LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/013-expected.txt.
+        * platform/mac-tiger/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt: Copied from LayoutTests/platform/mac/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt.
+        * platform/mac/http/tests/xmlhttprequest: Removed.
+        * platform/mac/http/tests/xmlhttprequest/web-apps: Removed.
+        * platform/mac/http/tests/xmlhttprequest/web-apps/012-expected.txt: Removed.
+        * platform/mac/http/tests/xmlhttprequest/web-apps/013-expected.txt: Removed.
+        * platform/mac/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt: Removed.
+        * platform/win/http/tests/xmlhttprequest: Removed.
+        * platform/win/http/tests/xmlhttprequest/web-apps: Removed.
+        * platform/win/http/tests/xmlhttprequest/web-apps/012-expected.txt: Removed.
+        * platform/win/http/tests/xmlhttprequest/web-apps/013-expected.txt: Removed.
+        * platform/win/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt: Removed.
+
 2010-04-09  Dumitru Daniliuc  <dumi@chromium.org>
 
         Unreviewed, rolling back the last two changes. The failing tests
diff --git a/LayoutTests/platform/mac-tiger/http/tests/xmlhttprequest/web-apps/013-expected.txt b/LayoutTests/platform/mac-tiger/http/tests/xmlhttprequest/web-apps/013-expected.txt
new file mode 100644 (file)
index 0000000..2c341f6
--- /dev/null
@@ -0,0 +1 @@
+FAIL: Status at readyState 3 was: 400, "OK"
diff --git a/LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/013-expected.txt b/LayoutTests/platform/mac/http/tests/xmlhttprequest/web-apps/013-expected.txt
deleted file mode 100644 (file)
index b687874..0000000
+++ /dev/null
@@ -1 +0,0 @@
-FAIL: Status at readyState 3 was: 400, "bad request"
diff --git a/LayoutTests/platform/mac/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt b/LayoutTests/platform/mac/http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception-expected.txt
deleted file mode 100644 (file)
index b94a670..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-This test checks that no exception is raised when getting a 404 HTTP response - that's success from XHR point of view.
-
-PASS: No exception.
-readyState: 4 (number)
-responseText: Non-empty (string)
-responseXML: null (object)
-status: 404 (number)
-statusText: not found (string)
-
diff --git a/LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/012-expected.txt b/LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/012-expected.txt
deleted file mode 100644 (file)
index 7ef22e9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-PASS
diff --git a/LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/013-expected.txt b/LayoutTests/platform/win/http/tests/xmlhttprequest/web-apps/013-expected.txt
deleted file mode 100644 (file)
index 7ef22e9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-PASS
index 204f1be..7f48481 100644 (file)
@@ -1,3 +1,27 @@
+2010-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24572
+        XMLHttpRequest.statusText returns always "OK" on Mac
+
+        Covered by existing tests, which now pass.
+
+        * WebCore.base.exp:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        Added a WebKitSystemInterface method to fetch status line.
+
+        * platform/network/HTTPParsers.cpp: (WebCore::extractReasonPhraseFromHTTPStatusLine):
+        * platform/network/HTTPParsers.h:
+        * platform/network/cf/ResourceResponseCFNet.cpp: (WebCore::ResourceResponse::platformLazyInit):
+        Moved code for parsing status line to HTTPHeaders, as it's used for both Mac and CF now.
+
+        * platform/network/mac/ResourceResponseMac.mm: (WebCore::ResourceResponse::platformLazyInit):
+        Use the actual reason phrase when available, and "OK" otherwise. Synthesizing a reson when
+        there isn't one is misleading, so we'll stick to our old broken behavior on Tiger, rather than
+        introduce a new broken one.
+
 2010-04-09  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Oliver Hunt.
index 1594ad7..315c7e8 100644 (file)
@@ -1037,6 +1037,7 @@ _suggestedFilenameWithMIMEType
 _wkAdvanceDefaultButtonPulseAnimation
 _wkCGContextGetShouldSmoothFonts
 _wkCopyCONNECTProxyResponse
+_wkCopyNSURLResponseStatusLine
 _wkCreateCustomCFReadStream
 _wkCreateNSURLConnectionDelegateProxy
 _wkCreateURLNPasteboardFlavorTypeName
index e7522a8..ea30023 100644 (file)
@@ -97,6 +97,7 @@ extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadS
     void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *), 
     void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
     void *context);
+extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
 extern id (*wkCreateNSURLConnectionDelegateProxy)(void);
 extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
 extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
index 5379686..b63c5c2 100644 (file)
@@ -29,6 +29,7 @@
 
 void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
 BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
+NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
 NSString* (*wkCreateURLPasteboardFlavorTypeName)(void);
 NSString* (*wkCreateURLNPasteboardFlavorTypeName)(void);
 void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
index 152a9d0..5a65e27 100644 (file)
@@ -295,4 +295,12 @@ XSSProtectionDisposition parseXSSProtectionHeader(const String& header)
     return XSSProtectionEnabled;
 }
 
+String extractReasonPhraseFromHTTPStatusLine(const String& statusLine)
+{
+    int spacePos = statusLine.find(' ');
+    // Remove status code from the status line.
+    spacePos = statusLine.find(' ', spacePos + 1);
+    return statusLine.substring(spacePos + 1);
+}
+
 }
index be4c4d3..06a2903 100644 (file)
@@ -55,6 +55,7 @@ String filenameFromHTTPContentDisposition(const String&);
 String extractMIMETypeFromMediaType(const String&);
 String extractCharsetFromMediaType(const String&); 
 XSSProtectionDisposition parseXSSProtectionHeader(const String&);
+String extractReasonPhraseFromHTTPStatusLine(const String&);
 
 }
 
index 95e9aff..469e5ad 100644 (file)
@@ -89,13 +89,7 @@ void ResourceResponse::platformLazyInit()
         m_httpStatusCode = CFHTTPMessageGetResponseStatusCode(httpResponse);
 
         RetainPtr<CFStringRef> statusLine(AdoptCF, CFHTTPMessageCopyResponseStatusLine(httpResponse));
-        String statusText(statusLine.get());
-        int spacePos = statusText.find(' ');
-        // Remove the status code from the status text.
-        spacePos = statusText.find(' ', spacePos + 1);
-        statusText = statusText.substring(spacePos + 1);      
-
-        m_httpStatusText = statusText;
+        m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(statusLine.get());
 
         RetainPtr<CFDictionaryRef> headers(AdoptCF, CFHTTPMessageCopyAllHeaderFields(httpResponse));
         CFIndex headerCount = CFDictionaryGetCount(headers.get());
index 334746e..e1f1790 100644 (file)
@@ -26,7 +26,9 @@
 #import "config.h"
 #import "ResourceResponse.h"
 
+#import "HTTPParsers.h"
 #import "WebCoreURLResponse.h"
+#import "WebCoreSystemInterface.h"
 #import <Foundation/Foundation.h>
 #import <wtf/StdLibExtras.h>
 #import <limits>
@@ -78,10 +80,12 @@ void ResourceResponse::platformLazyInit()
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();
         
         m_httpStatusCode = [httpResponse statusCode];
-        
-        // we used to return "OK" for everything, so be compatible and return "OK" for 200.
-        m_httpStatusText = m_httpStatusCode == 200 ? String("OK") 
-            : String([NSHTTPURLResponse localizedStringForStatusCode: m_httpStatusCode]);
+
+        RetainPtr<NSString> httpStatusLine(AdoptNS, wkCopyNSURLResponseStatusLine(m_nsResponse.get()));
+        if (httpStatusLine)
+            m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(httpStatusLine.get());
+        else
+            m_httpStatusText = "OK";
         
         NSDictionary *headers = [httpResponse allHeaderFields];
         NSEnumerator *e = [headers keyEnumerator];
index 4d57bd5..60277dc 100644 (file)
@@ -1,3 +1,12 @@
+2010-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24572
+        XMLHttpRequest.statusText returns always "OK" on Mac
+
+        * WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface):
+
 2010-04-09  Eric Seidel  <eric@webkit.org>
 
         Unreviewed, rolling out r57343.
index 46138e5..b792707 100644 (file)
@@ -45,6 +45,7 @@ void InitWebCoreSystemInterface(void)
     INIT(AdvanceDefaultButtonPulseAnimation);
     INIT(CGContextGetShouldSmoothFonts);
     INIT(CopyCONNECTProxyResponse);
+    INIT(CopyNSURLResponseStatusLine);
     INIT(CreateCustomCFReadStream);
     INIT(CreateNSURLConnectionDelegateProxy);
     INIT(DrawCapsLockIndicator);
index 9b9d4ab..ce443c0 100644 (file)
@@ -1,3 +1,15 @@
+2010-04-09  Alexey Proskuryakov  <ap@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24572
+        XMLHttpRequest.statusText returns always "OK" on Mac
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+        * libWebKitSystemInterfaceTiger.a:
+
 2010-04-07  Chris Marrin  <cmarrin@apple.com>
 
         Reviewed by Steve Falkenburg.
index 8ead4ec..18b612c 100644 (file)
@@ -29,8 +29,9 @@ NSString *WKGetPreferredExtensionForMIMEType(NSString *type);
 NSArray *WKGetExtensionsForMIMEType(NSString *type);
 NSString *WKGetMIMETypeForExtension(NSString *extension);
 
-NSDate *WKGetNSURLResponseLastModifiedDate(NSURLResponse *response);
-NSTimeInterval WKGetNSURLResponseFreshnessLifetime(NSURLResponse *response);
+NSDate *WKGetNSURLResponseLastModifiedDate(NSURLResponse *);
+NSTimeInterval WKGetNSURLResponseFreshnessLifetime(NSURLResponse *);
+NSString *WKCopyNSURLResponseStatusLine(NSURLResponse *);
 
 CFStringEncoding WKGetWebDefaultCFStringEncoding(void);
 
index 41fcba3..673465f 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index 18c1246..20d0bae 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ
index 9256abf..bcb6ab3 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceTiger.a and b/WebKitLibraries/libWebKitSystemInterfaceTiger.a differ