LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 19:01:39 +0000 (19:01 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 19:01:39 +0000 (19:01 +0000)
        Reviewed by Anders.

        - fixed "REGRESSION: Can't order from Pizza Hut (ToT, 05/24/06)"
        http://bugzilla.opendarwin.org/show_bug.cgi?id=9103

        * http/tests/misc/redirect-expected.txt: Added.
        * http/tests/misc/redirect.php: Added.
        * http/tests/misc/resources/redirect-result.php: Added.

WebKit:

        Reviewed by Anders.

        - fixed "REGRESSION: Can't order from Pizza Hut (ToT, 05/24/06)"
        http://bugzilla.opendarwin.org/show_bug.cgi?id=9103

        * WebView/WebDataSource.m:
        (-[WebDataSource _willSendRequest:forResource:redirectResponse:]): Set up the
        User-Agent header.
        * WebView/WebDataSourceInternal.h:
        * WebView/WebLoader.m:
        (-[NSURLProtocol willSendRequest:redirectResponse:]): Pass a mutable URL request
        so the above can work.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/redirect.php [new file with mode: 0644]
LayoutTests/http/tests/misc/resources/redirect-result.php [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebView/WebDataSource.m
WebKit/WebView/WebDataSourceInternal.h
WebKit/WebView/WebLoader.m

index 1772eb12b7c3634d9c520ab3c7c24af0935be6c9..055de77cd1c8553b82a0f786941e9003a9c2a147 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-01  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+        
+        - fixed "REGRESSION: Can't order from Pizza Hut (ToT, 05/24/06)"
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9103
+
+        * http/tests/misc/redirect-expected.txt: Added.
+        * http/tests/misc/redirect.php: Added.
+        * http/tests/misc/resources/redirect-result.php: Added.
+
 2006-06-01  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/http/tests/misc/redirect-expected.txt b/LayoutTests/http/tests/misc/redirect-expected.txt
new file mode 100644 (file)
index 0000000..1e3f579
--- /dev/null
@@ -0,0 +1 @@
+PASS: User-Agent header contains the string 'WebKit'.
diff --git a/LayoutTests/http/tests/misc/redirect.php b/LayoutTests/http/tests/misc/redirect.php
new file mode 100644 (file)
index 0000000..7546946
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+  header('Location: resources/redirect-result.php');
+  header('HTTP/1.0 302 Found');
+?>
diff --git a/LayoutTests/http/tests/misc/resources/redirect-result.php b/LayoutTests/http/tests/misc/resources/redirect-result.php
new file mode 100644 (file)
index 0000000..e081e34
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<body>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var userAgent = "<?php $headers = getallheaders(); echo $headers["User-Agent"]; ?>";
+if (userAgent.match(/WebKit/)) {
+    document.write("PASS: User-Agent header contains the string 'WebKit'.");
+} else {
+    document.write("FAIL: User-Agent header does not contain the string 'WebKit', value is '" + userAgent + "'");
+}
+</script>
+
+</body>
+</html>
index d6e45b4ec02e8dcffef28f078dfcae48f6a5116f..022cdbdc02b04edbdcf838bdeb975e3d1389a898 100644 (file)
@@ -1,3 +1,18 @@
+2006-06-01  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+        
+        - fixed "REGRESSION: Can't order from Pizza Hut (ToT, 05/24/06)"
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9103
+
+        * WebView/WebDataSource.m:
+        (-[WebDataSource _willSendRequest:forResource:redirectResponse:]): Set up the
+        User-Agent header.
+        * WebView/WebDataSourceInternal.h:
+        * WebView/WebLoader.m:
+        (-[NSURLProtocol willSendRequest:redirectResponse:]): Pass a mutable URL request
+        so the above can work.
+
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
index 71054e946a4f32aa04588b0fec3c10e5aa6ea9b5..ec6372bec4c70f8656b822cc1ca529274bd46499 100644 (file)
@@ -53,6 +53,7 @@
 #import "WebMainResourceLoader.h"
 #import "WebNSObjectExtras.h"
 #import "WebNSURLExtras.h"
+#import "WebNSURLRequestExtras.h"
 #import "WebPDFRepresentation.h"
 #import "WebPreferences.h"
 #import "WebResourceLoadDelegate.h"
@@ -873,11 +874,12 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
         return [[[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:webView identifierForInitialRequest:clientRequest fromDataSource:self] retain];
 }
 
-- (NSURLRequest *)_willSendRequest:(NSURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse
+- (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse
 {
     WebView *webView = [self _webView];
 
-    // If we have a special "applewebdata" scheme URL we send a fake request to the delegate.
+    [clientRequest _web_setHTTPUserAgent:[webView userAgentForURL:[clientRequest URL]]];
+
     if ([webView _resourceLoadDelegateImplementations].delegateImplementsWillSendRequest)
         return [[webView resourceLoadDelegate] webView:webView resource:identifier willSendRequest:clientRequest redirectResponse:redirectResponse fromDataSource:self];
     else
index ecb6e5033050496755f67f88b22c23eccef06a2e..946bd0f62cd7b1d9b65a64330f5474e6f1ecbbc8 100644 (file)
 - (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
 - (BOOL)_defersCallbacks;
 - (id)_identifierForInitialRequest:(NSURLRequest *)clientRequest;
-- (NSURLRequest *)_willSendRequest:(NSURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
+- (NSURLRequest *)_willSendRequest:(NSMutableURLRequest *)clientRequest forResource:(id)identifier redirectResponse:(NSURLResponse *)redirectResponse;
 - (void)_didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
 - (void)_didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)currentWebChallenge forResource:(id)identifier;
 - (void)_didReceiveResponse:(NSURLResponse *)r forResource:(id)identifier;
index 6d381b0b74d808106d780221d7f7575154010ae2..0c3611db37477874c4a85d74bfdbca7de4c2960a 100644 (file)
@@ -335,19 +335,21 @@ static BOOL NSURLConnectionSupportsBufferedData;
 - (NSURLRequest *)willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
 {
     ASSERT(!reachedTerminalState);
-    NSMutableURLRequest *mutableRequest = [newRequest mutableCopy];
-    NSURLRequest *clientRequest, *updatedRequest;
+    NSMutableURLRequest *mutableRequest = [[newRequest mutableCopy] autorelease];
+    NSMutableURLRequest *clientRequest;
+    NSURLRequest *updatedRequest;
     BOOL haveDataSchemeRequest = NO;
     
     // retain/release self in this delegate method since the additional processing can do
     // anything including possibly releasing self; one example of this is 3266216
     [self retain];
 
-    newRequest = [mutableRequest autorelease];
+    newRequest = mutableRequest;
 
-    clientRequest = [newRequest _webDataRequestExternalRequest];
+    // If we have a special "applewebdata" scheme URL we send a fake request to the delegate.
+    clientRequest = [mutableRequest _webDataRequestExternalRequest];
     if (!clientRequest)
-        clientRequest = newRequest;
+        clientRequest = mutableRequest;
     else
         haveDataSchemeRequest = YES;
     
@@ -378,13 +380,7 @@ static BOOL NSURLConnectionSupportsBufferedData;
     // Store a copy of the request.
     [request autorelease];
 
-    // Client may return a nil request, indicating that the request should be aborted.
-    if (newRequest){
-        request = [newRequest copy];
-    }
-    else {
-        request = nil;
-    }
+    request = [newRequest copy];
 
     [self release];
     return request;