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
+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
@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
// 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.
@end
@interface NSURLRequest (WebDataRequest)
++ (NSString *)_webDataRequestPropertyKey;
- (NSURL *)_webDataRequestBaseURL;
- (NSURL *)_webDataRequestUnreachableURL;
- (NSURL *)_webDataRequestExternalURL;
@implementation NSURLRequest (WebDataRequest)
++ (NSString *)_webDataRequestPropertyKey
+{
+ return WebDataRequestPropertyKey;
+}
+
- (WebDataRequestParameters *)_webDataRequestParametersForReading
{
return [NSURLProtocol propertyForKey:WebDataRequestPropertyKey inRequest:self];
@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
// 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.