Changeset 47509 in webkit
- Timestamp:
- Aug 19, 2009 10:33:32 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47508 r47509 1 2009-08-19 Brady Eidson <beidson@apple.com> 2 3 Reviewed by Kevin Decker. 4 5 <rdar://problem/7042555> Loading certain pages on Tiger will start a spurious download 6 7 Get rid of method swizzling entirely. This created problems when lower level 8 Foundation code would call into our own swizzled method. 9 10 * platform/network/mac/ResourceHandleMac.mm: 11 (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]): 12 * platform/network/mac/WebCoreURLResponse.h: 13 * platform/network/mac/WebCoreURLResponse.mm: 14 (-[NSURLResponse adjustMIMETypeIfNecessary]): 15 1 16 2009-08-19 Adam Roben <aroben@apple.com> 2 17 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r47481 r47509 17552 17552 runOnlyForDeploymentPostprocessing = 0; 17553 17553 shellPath = /bin/sh; 17554 shellScript = " if [ \"${ACTION}\" = \"installhdrs\" ]; then\n exit 0;\nfi\n\nif [ -f ../WebKitTools/Scripts/check-for-global-initializers ]; then\n ../WebKitTools/Scripts/check-for-global-initializers || exit $?\nfi";17554 shellScript = ""; 17555 17555 }; 17556 17556 DD041FBD09D9DDBE0010AF2A /* Generate Derived Sources */ = { -
trunk/WebCore/platform/network/mac/ResourceHandleMac.mm
r46548 r47509 1 1 /* 2 * Copyright (C) 2004, 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2004, 2006-2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 65 65 @end 66 66 67 @interface NSURLResponse (Details)68 - (void)_setMIMEType:(NSString *)type;69 @end70 71 67 @interface NSURLRequest (Details) 72 68 - (id)_propertyForKey:(NSString *)key; … … 636 632 UNUSED_PARAM(connection); 637 633 638 LOG(Network, "Handle %p delegate connection:%p didReceiveResponse:%p (HTTP status %d, MIMEType '%s', reported MIMEType '%s')", m_handle, connection, r, [r respondsToSelector:@selector(statusCode)] ? [(id)r statusCode] : 0, [[r MIMEType] UTF8String], [[r _webcore_reportedMIMEType] UTF8String]);634 LOG(Network, "Handle %p delegate connection:%p didReceiveResponse:%p (HTTP status %d, reported MIMEType '%s')", m_handle, connection, r, [r respondsToSelector:@selector(statusCode)] ? [(id)r statusCode] : 0, [[r MIMEType] UTF8String]); 639 635 640 636 if (!m_handle || !m_handle->client()) … … 642 638 CallbackGuard guard; 643 639 644 swizzleMIMETypeMethodIfNecessary();640 [r adjustMIMETypeIfNecessary]; 645 641 646 642 if ([m_handle->request().nsURLRequest() _propertyForKey:@"ForceHTMLMIMEType"]) -
trunk/WebCore/platform/network/mac/WebCoreURLResponse.h
r45476 r47509 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 @interface NSURLResponse (WebCoreURLResponse) 30 -( NSString *)_webcore_reportedMIMEType;30 -(void)adjustMIMETypeIfNecessary; 31 31 @end 32 32 33 void swizzleMIMETypeMethodIfNecessary(); 33 @interface NSURLResponse (Details) 34 - (void)_setMIMEType:(NSString *)type; 35 @end -
trunk/WebCore/platform/network/mac/WebCoreURLResponse.mm
r45499 r47509 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 328 328 } 329 329 330 static IMP oldNSURLResponseMIMETypeIMP = 0;331 static NSString *webNSURLResponseMIMEType(id, SEL);332 333 void swizzleMIMETypeMethodIfNecessary()334 {335 if (!oldNSURLResponseMIMETypeIMP) {336 Method nsURLResponseMIMETypeMethod = class_getInstanceMethod([NSURLResponse class], @selector(MIMEType));337 ASSERT(nsURLResponseMIMETypeMethod);338 #ifdef BUILDING_ON_TIGER339 oldNSURLResponseMIMETypeIMP = nsURLResponseMIMETypeMethod->method_imp;340 nsURLResponseMIMETypeMethod->method_imp = (IMP)webNSURLResponseMIMEType;341 #else342 oldNSURLResponseMIMETypeIMP = method_setImplementation(nsURLResponseMIMETypeMethod, (IMP)webNSURLResponseMIMEType);343 #endif344 }345 }346 347 330 static NSString *mimeTypeFromUTITree(CFStringRef uti) 348 331 { … … 380 363 } 381 364 382 static NSString *webNSURLResponseMIMEType(id self, SEL _cmd) 365 @implementation NSURLResponse (WebCoreURLResponse) 366 367 -(void)adjustMIMETypeIfNecessary 383 368 { 384 ASSERT(oldNSURLResponseMIMETypeIMP);385 NSString * result = oldNSURLResponseMIMETypeIMP(self, _cmd);369 NSString *result = [self MIMEType]; 370 NSString *originalResult = result; 386 371 387 372 #ifdef BUILDING_ON_TIGER … … 419 404 // <rdar://problem/5321972> Plain text document from HTTP server detected as application/octet-stream 420 405 // Make the best guess when deciding between "generic binary" and "generic text" using a table of known binary MIME types. 421 if ([result isEqualToString:@"application/octet-stream"] && [self respondsToSelector:@selector(allHeaderFields)] && [[[self allHeaderFields] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"]) {406 if ([result isEqualToString:@"application/octet-stream"] && [self respondsToSelector:@selector(allHeaderFields)] && [[[self performSelector:@selector(allHeaderFields)] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"]) { 422 407 static NSSet *binaryExtensions = createBinaryExtensionsSet(); 423 408 if (![binaryExtensions containsObject:[[[self suggestedFilename] pathExtension] lowercaseString]]) … … 433 418 #endif 434 419 435 return result; 420 if (result != originalResult) 421 [self _setMIMEType:result]; 436 422 } 437 423 438 @implementation NSURLResponse (WebCoreURLResponse)439 440 -(NSString *)_webcore_reportedMIMEType441 {442 swizzleMIMETypeMethodIfNecessary();443 return oldNSURLResponseMIMETypeIMP(self, @selector(_webcore_realMIMEType));444 }445 446 424 @end
Note: See TracChangeset
for help on using the changeset viewer.