Changeset 30323 in webkit


Ignore:
Timestamp:
Feb 15, 2008 1:30:48 PM (16 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Alexey Proskuryakov.

Test: http/tests/loading/text-content-type-with-binary-extension.html

Refined the workaround for <rdar://problem/5321972> to exclude files
with extensions that are known to be associated with binary MIME types.

  • WebCore.xcodeproj/project.pbxproj: Added WebCoreURLResponse.{h,mm}.
  • platform/network/mac/ResourceResponseMac.mm: (WebCore::ResourceResponse::doUpdateResourceResponse): Moved the workaround logic into WebCoreURLResponse.
  • platform/network/mac/WebCoreURLResponse.h: Added.
  • platform/network/mac/WebCoreURLResponse.mm: Added. (createBinaryExtensionsSet): Returns a set of extensions known to belong to MIME types of binary data. (-[NSURLResponse _webcore_MIMEType]): (-[NSHTTPURLResponse _webcore_MIMEType]): Forces the MIME type from application/octet-stream to text/plain if that is the specified Content-Type, unless the extension is in the binary extensions set.

WebKit/mac:

Reviewed by Alexey Proskuryakov.

  • WebView/WebDataSource.mm: (+[WebDataSource _representationClassForMIMEType:]): (-[WebDataSource _responseMIMEType]): (-[WebDataSource subresources]): (-[WebDataSource subresourceForURL:]):
  • WebView/WebResource.mm: (-[WebResource _initWithData:URL:response:]):
  • WebView/WebResourcePrivate.h:

LayoutTests:

Reviewed by Alexey Proskuryakov.

  • http/tests/loading/resources/.htaccess: Added.
  • http/tests/loading/resources/binaryData.m4a: Added.
  • http/tests/loading/text-content-type-with-binary-extension-expected.txt: Added.
  • http/tests/loading/text-content-type-with-binary-extension.html: Added.
Location:
trunk
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r30320 r30323  
     12008-02-15  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=17360
     6          <rdar://problem/5743131> REGRESSION: mp4 file downloaded from server is downloaded as html
     7
     8        * http/tests/loading/resources/.htaccess: Added.
     9        * http/tests/loading/resources/binaryData.m4a: Added.
     10        * http/tests/loading/text-content-type-with-binary-extension-expected.txt: Added.
     11        * http/tests/loading/text-content-type-with-binary-extension.html: Added.
     12
    1132008-02-15  Samuel Weinig  <sam@webkit.org>
    214
  • trunk/WebCore/ChangeLog

    r30319 r30323  
     12008-02-15  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        - WebCore part of fixing http://bugs.webkit.org/show_bug.cgi?id=17360
     6          <rdar://problem/5743131> REGRESSION: mp4 file downloaded from server is downloaded as html
     7
     8        Test: http/tests/loading/text-content-type-with-binary-extension.html
     9
     10        Refined the workaround for <rdar://problem/5321972> to exclude files
     11        with extensions that are known to be associated with binary MIME types.
     12
     13        * WebCore.xcodeproj/project.pbxproj: Added WebCoreURLResponse.{h,mm}.
     14        * platform/network/mac/ResourceResponseMac.mm:
     15        (WebCore::ResourceResponse::doUpdateResourceResponse): Moved the
     16        workaround logic into WebCoreURLResponse.
     17        * platform/network/mac/WebCoreURLResponse.h: Added.
     18        * platform/network/mac/WebCoreURLResponse.mm: Added.
     19        (createBinaryExtensionsSet): Returns a set of extensions known to
     20        belong to MIME types of binary data.
     21        (-[NSURLResponse _webcore_MIMEType]):
     22        (-[NSHTTPURLResponse _webcore_MIMEType]): Forces the MIME type from
     23        application/octet-stream to text/plain if that is the specified
     24        Content-Type, unless the extension is in the binary extensions set.
     25
    1262008-02-15  Dan Bernstein  <mitz@apple.com>
    227
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r30172 r30323  
    310310                37919C230B7D188600A56998 /* PositionIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37919C210B7D188600A56998 /* PositionIterator.cpp */; };
    311311                37919C240B7D188600A56998 /* PositionIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 37919C220B7D188600A56998 /* PositionIterator.h */; settings = {ATTRIBUTES = (); }; };
     312                37F818FD0D657606005E1F05 /* WebCoreURLResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
     313                37F818FE0D657606005E1F05 /* WebCoreURLResponse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */; };
    312314                441B05560CD779B6007C1F18 /* DOMCSSStyleSheetPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 4429AAEA0CB84DC7007647C5 /* DOMCSSStyleSheetPrivate.h */; };
    313315                441B05580CD779F2007C1F18 /* DOMEventPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 4429AAF80CB84E5F007647C5 /* DOMEventPrivate.h */; };
     
    45654567                37919C210B7D188600A56998 /* PositionIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PositionIterator.cpp; sourceTree = "<group>"; };
    45664568                37919C220B7D188600A56998 /* PositionIterator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PositionIterator.h; sourceTree = "<group>"; };
     4569                37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreURLResponse.h; sourceTree = "<group>"; };
     4570                37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponse.mm; sourceTree = "<group>"; };
    45674571                441244D80CB853ED008F0C79 /* JSHTMLInputElementBaseTable.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 30; path = JSHTMLInputElementBaseTable.cpp; sourceTree = "<group>"; };
    45684572                4429AAEA0CB84DC7007647C5 /* DOMCSSStyleSheetPrivate.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; path = DOMCSSStyleSheetPrivate.h; sourceTree = "<group>"; };
     
    82988302                                514C764A0CE9234E007EF3CD /* ResourceResponse.h */,
    82998303                                514C764B0CE9234E007EF3CD /* ResourceResponseMac.mm */,
     8304                                37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */,
     8305                                37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */,
    83008306                        );
    83018307                        path = mac;
     
    1423214238                                C0294DF40D5A6FD800CC7D6B /* UserStyleSheetLoader.h in Headers */,
    1423314239                                E1DE1C080D5CE4CF0034C38F /* MessageQueue.h in Headers */,
     14240                                37F818FD0D657606005E1F05 /* WebCoreURLResponse.h in Headers */,
    1423414241                        );
    1423514242                        runOnlyForDeploymentPostprocessing = 0;
     
    1582515832                                51A9267E0D53F0570063ECC2 /* OriginUsageRecord.cpp in Sources */,
    1582615833                                C0294DF30D5A6FD800CC7D6B /* UserStyleSheetLoader.cpp in Sources */,
     15834                                37F818FE0D657606005E1F05 /* WebCoreURLResponse.mm in Sources */,
    1582715835                        );
    1582815836                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/platform/network/mac/ResourceResponseMac.mm

    r30243 r30323  
    2828#import "ResourceResponse.h"
    2929
     30#import "WebCoreURLResponse.h"
    3031#import <Foundation/Foundation.h>
    3132#import <limits>
     
    6566   
    6667    m_url = [m_nsResponse.get() URL];
    67     m_mimeType = [m_nsResponse.get() MIMEType];
     68    m_mimeType = [m_nsResponse.get() _webcore_MIMEType];
    6869    m_expectedContentLength = [m_nsResponse.get() expectedContentLength];
    6970    m_textEncodingName = [m_nsResponse.get() textEncodingName];
     
    8889        while (NSString *name = [e nextObject])
    8990            m_httpHeaderFields.set(name, [headers objectForKey:name]);
    90 #ifndef BUILDING_ON_TIGER
    91         // FIXME: This is part of a workaround for <rdar://problem/5321972> REGRESSION: Plain text document from HTTP server detected
    92         // as application/octet-stream
    93         if (m_mimeType == "application/octet-stream") {
    94             static const String textPlainMIMEType("text/plain");
    95             if (m_httpHeaderFields.get("Content-Type").startsWith(textPlainMIMEType))
    96                 m_mimeType = textPlainMIMEType;
    97         }
    98 #endif
    9991    } else {
    10092        m_httpStatusCode = 0;
  • trunk/WebKit/mac/ChangeLog

    r30276 r30323  
     12008-02-15  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        - WebKit part of fixing http://bugs.webkit.org/show_bug.cgi?id=17360
     6          <rdar://problem/5743131> REGRESSION: mp4 file downloaded from server is downloaded as html
     7
     8        * WebView/WebDataSource.mm:
     9        (+[WebDataSource _representationClassForMIMEType:]):
     10        (-[WebDataSource _responseMIMEType]):
     11        (-[WebDataSource subresources]):
     12        (-[WebDataSource subresourceForURL:]):
     13        * WebView/WebResource.mm:
     14        (-[WebResource _initWithData:URL:response:]):
     15        * WebView/WebResourcePrivate.h:
     16
    1172008-02-15  Adam Roben  <aroben@apple.com>
    218
  • trunk/WebKit/mac/WebView/WebDataSource.mm

    r30243 r30323  
    5656#import <WebCore/SharedBuffer.h>
    5757#import <WebCore/WebCoreObjCExtras.h>
     58#import <WebCore/WebCoreURLResponse.h>
    5859#import <WebKit/DOMHTML.h>
    5960#import <WebKit/DOMPrivate.h>
     
    136137    return [WebView _viewClass:nil andRepresentationClass:&repClass forMIMEType:MIMEType] ? repClass : nil;
    137138}
    138 
    139 - (NSString *)_MIMETypeOfResponse:(NSURLResponse *)response
    140 {
    141 #ifdef BUILDING_ON_TIGER
    142     return [response MIMEType];
    143 #else
    144     // FIXME: This is part of a workaround for <rdar://problem/5321972> REGRESSION: Plain text document from HTTP server detected
    145     // as application/octet-stream
    146     NSString *MIMEType = [response MIMEType];
    147     if ([MIMEType isEqualToString:@"application/octet-stream"] && [response isKindOfClass:[NSHTTPURLResponse class]] && [[[(NSHTTPURLResponse *)response allHeaderFields] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"])
    148         return @"text/plain";
    149     return MIMEType;
    150 #endif
    151 }
    152139@end
    153140
     
    190177- (NSString *)_responseMIMEType
    191178{
    192 #ifdef BUILDING_ON_TIGER
    193     return [[self response] MIMEType];
    194 #else
    195     return [self _MIMETypeOfResponse:[self response]];
    196 #endif
     179    return [[self response] _webcore_MIMEType];
    197180}
    198181
     
    516499    for (unsigned i = 0; i < [datas count]; ++i) {
    517500        NSURLResponse *response = [responses objectAtIndex:i];
    518         [subresources addObject:[[[WebResource alloc] _initWithData:[datas objectAtIndex:i] URL:[response URL] response:response MIMEType:[self _MIMETypeOfResponse:response]] autorelease]];
     501        [subresources addObject:[[[WebResource alloc] _initWithData:[datas objectAtIndex:i] URL:[response URL] response:response] autorelease]];
    519502    }
    520503
     
    532515        return [self _archivedSubresourceForURL:URL];
    533516
    534     return [[[WebResource alloc] _initWithData:data URL:URL response:response MIMEType:[self _MIMETypeOfResponse:response]] autorelease];
     517    return [[[WebResource alloc] _initWithData:data URL:URL response:response] autorelease];
    535518}
    536519
  • trunk/WebKit/mac/WebView/WebResource.mm

    r26758 r30323  
    3232#import "WebNSDictionaryExtras.h"
    3333#import "WebNSURLExtras.h"
     34#import <WebCore/WebCoreURLResponse.h>
    3435
    3536static NSString * const WebResourceDataKey =              @"WebResourceData";
     
    249250}
    250251
    251 - (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response MIMEType:(NSString *)MIMEType
     252- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response
    252253{
    253254    // Pass NO for copyData since the data doesn't need to be copied since we know that callers will no longer modify it.
     
    255256    return [self _initWithData:data
    256257                           URL:URL
    257                       MIMEType:MIMEType
     258                      MIMEType:[response _webcore_MIMEType]
    258259              textEncodingName:[response textEncodingName]
    259260                     frameName:nil
  • trunk/WebKit/mac/WebView/WebResourcePrivate.h

    r26758 r30323  
    3939           copyData:(BOOL)copyData;
    4040
    41 - (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response MIMEType:(NSString *)MIMEType;
     41- (id)_initWithData:(NSData *)data URL:(NSURL *)URL response:(NSURLResponse *)response;
    4242
    4343- (BOOL)_shouldIgnoreWhenUnarchiving;
Note: See TracChangeset for help on using the changeset viewer.