Fixed <rdar://problem/4040321> Exception: Someone's trying to encode a WebDataReques...
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2005 00:00:39 +0000 (00:00 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Mar 2005 00:00:39 +0000 (00:00 +0000)
If client mutates request use new Foundation SPI to address remove applewebdata properties from request.

        Reviewed by Ken Kocienda.

        * WebView.subproj/WebBaseResourceHandleDelegate.m:
        (-[WebBaseResourceHandleDelegate willSendRequest:redirectResponse:]):
        * WebView.subproj/WebDataProtocol.h:
        * WebView.subproj/WebDataProtocol.m:
        (+[NSURLRequest _webDataRequestPropertyKey]):

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

WebKit/ChangeLog
WebKit/WebView.subproj/WebBaseResourceHandleDelegate.m
WebKit/WebView.subproj/WebDataProtocol.h
WebKit/WebView.subproj/WebDataProtocol.m
WebKit/WebView.subproj/WebLoader.m

index 976acb6cc691c44721a4dedd9165eaccb2a6a536..854ee2d61cd937d8e088ec88b93b9f37dcd48173 100644 (file)
@@ -1,3 +1,17 @@
+2005-03-15  Richard Williamson   <rjw@apple.com>
+
+       Fixed <rdar://problem/4040321> Exception: Someone's trying to encode a WebDataRequestParameters instance
+
+       If client mutates request use new Foundation SPI to address remove applewebdata properties      from request.
+
+        Reviewed by Ken Kocienda.
+
+        * WebView.subproj/WebBaseResourceHandleDelegate.m:
+        (-[WebBaseResourceHandleDelegate willSendRequest:redirectResponse:]):
+        * WebView.subproj/WebDataProtocol.h:
+        * WebView.subproj/WebDataProtocol.m:
+        (+[NSURLRequest _webDataRequestPropertyKey]):
+
 2005-03-15  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Vicki
index 91f24b1453171c4416b61f316a84f99028adbf23..72af129f3a669ccacd2a1d5b8444e29cd6c8027b 100644 (file)
@@ -79,6 +79,12 @@ static BOOL NSURLConnectionSupportsBufferedData;
 
 @end
 
+// This declaration is only needed to ease the transition to a new SPI.  It can be removed
+// moving forward beyond Tiger 8A416.
+@interface NSURLProtocol (WebFoundationSecret) 
++ (void)_removePropertyForKey:(NSString *)key inRequest:(NSMutableURLRequest *)request;
+@end
+
 @implementation WebBaseResourceHandleDelegate
 
 + (void)initialize
@@ -373,8 +379,17 @@ static BOOL NSURLConnectionSupportsBufferedData;
         // If the delegate modified the request use that instead of
         // our applewebdata request, otherwise use the original
         // applewebdata request.
-        if (![updatedRequest isEqual:clientRequest])
+        if (![updatedRequest isEqual:clientRequest]) {
             newRequest = updatedRequest;
+        
+            // The respondsToSelector: check is only necessary for people building/running prior to Tier 8A416.
+            if ([NSURLProtocol respondsToSelector:@selector(_removePropertyForKey:inRequest:)] &&
+                [newRequest isKindOfClass:[NSMutableURLRequest class]]) {
+                NSMutableURLRequest *mr = (NSMutableURLRequest *)newRequest;
+                [NSURLProtocol _removePropertyForKey:[NSURLRequest _webDataRequestPropertyKey] inRequest:mr];
+            }
+
+        }
     }
 
     // Store a copy of the request.
index caf43299c16a2a5cec55db9136d23eaf27915124..80fac4eaba2496888081781e9cc662c6989601be 100644 (file)
@@ -23,6 +23,7 @@
 @end
 
 @interface NSURLRequest (WebDataRequest)
++ (NSString *)_webDataRequestPropertyKey;
 - (NSURL *)_webDataRequestBaseURL;
 - (NSURL *)_webDataRequestUnreachableURL;
 - (NSURL *)_webDataRequestExternalURL;
index d1e6e5c63469c00d633d2cea3c8ab98db5d5fb02..21c0cddd58c77ed631f4f098f63589464671ac9b 100644 (file)
@@ -79,6 +79,11 @@ static NSString *WebDataRequestPropertyKey = @"WebDataRequest";
 
 @implementation NSURLRequest (WebDataRequest)
 
++ (NSString *)_webDataRequestPropertyKey
+{
+    return WebDataRequestPropertyKey;
+}
+
 - (WebDataRequestParameters *)_webDataRequestParametersForReading
 {
     return [NSURLProtocol propertyForKey:WebDataRequestPropertyKey inRequest:self];
index 91f24b1453171c4416b61f316a84f99028adbf23..72af129f3a669ccacd2a1d5b8444e29cd6c8027b 100644 (file)
@@ -79,6 +79,12 @@ static BOOL NSURLConnectionSupportsBufferedData;
 
 @end
 
+// This declaration is only needed to ease the transition to a new SPI.  It can be removed
+// moving forward beyond Tiger 8A416.
+@interface NSURLProtocol (WebFoundationSecret) 
++ (void)_removePropertyForKey:(NSString *)key inRequest:(NSMutableURLRequest *)request;
+@end
+
 @implementation WebBaseResourceHandleDelegate
 
 + (void)initialize
@@ -373,8 +379,17 @@ static BOOL NSURLConnectionSupportsBufferedData;
         // If the delegate modified the request use that instead of
         // our applewebdata request, otherwise use the original
         // applewebdata request.
-        if (![updatedRequest isEqual:clientRequest])
+        if (![updatedRequest isEqual:clientRequest]) {
             newRequest = updatedRequest;
+        
+            // The respondsToSelector: check is only necessary for people building/running prior to Tier 8A416.
+            if ([NSURLProtocol respondsToSelector:@selector(_removePropertyForKey:inRequest:)] &&
+                [newRequest isKindOfClass:[NSMutableURLRequest class]]) {
+                NSMutableURLRequest *mr = (NSMutableURLRequest *)newRequest;
+                [NSURLProtocol _removePropertyForKey:[NSURLRequest _webDataRequestPropertyKey] inRequest:mr];
+            }
+
+        }
     }
 
     // Store a copy of the request.