Changeset 204128 in webkit


Ignore:
Timestamp:
Aug 4, 2016 11:48:16 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Temporary redirected m3u8 streaming stopped working.
https://bugs.webkit.org/show_bug.cgi?id=160472
rdar://problem/27592694

Patch by Jeremy Jones <jeremyj@apple.com> on 2016-08-04
Reviewed by Alex Christensen.

Source/WebCore:

Test: http/tests/media/hls/hls-redirect.html

The change for https://trac.webkit.org/changeset/202466 hides knowledge of the temporary redirected URL from
WebCoreNSURLSession clients. MPEG playlists (e.g. .m3u8) can contain paths relative to the redirected URL.

This change exposes the redirected URL for MPEG playlists.

  • platform/MIMETypeRegistry.cpp:

(WebCore::initializeMPEGPlaylistMIMETypes): Added.
(WebCore::initializeMIMETypeRegistry):
(WebCore::MIMETypeRegistry::isMPEGPlaylistMIMEType): Added.

  • platform/MIMETypeRegistry.h:
  • platform/network/cocoa/WebCoreNSURLSession.mm:

(-[WebCoreNSURLSessionDataTask resource:receivedResponse:]): Add MPEG playlist condition.
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:]): Add MPEG playlist condition.

LayoutTests:

This tests that m3u8 files can be loaded when going through a temporary redirect.

  • http/tests/media/hls/hls-redirect-expected.txt: Added.
  • http/tests/media/hls/hls-redirect.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r204127 r204128  
     12016-08-04  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Temporary redirected m3u8 streaming stopped working.
     4        https://bugs.webkit.org/show_bug.cgi?id=160472
     5        rdar://problem/27592694
     6
     7        Reviewed by Alex Christensen.
     8
     9        This tests that m3u8 files can be loaded when going through a temporary redirect.
     10
     11        * http/tests/media/hls/hls-redirect-expected.txt: Added.
     12        * http/tests/media/hls/hls-redirect.html: Added.
     13
    1142016-08-04  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r204127 r204128  
     12016-08-04  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Temporary redirected m3u8 streaming stopped working.
     4        https://bugs.webkit.org/show_bug.cgi?id=160472
     5        rdar://problem/27592694
     6
     7        Reviewed by Alex Christensen.
     8
     9        Test: http/tests/media/hls/hls-redirect.html
     10
     11        The change for https://trac.webkit.org/changeset/202466 hides knowledge of the temporary redirected URL from
     12        WebCoreNSURLSession clients. MPEG playlists (e.g. .m3u8) can contain paths relative to the redirected URL.
     13
     14        This change exposes the redirected URL for MPEG playlists.
     15
     16        * platform/MIMETypeRegistry.cpp:
     17        (WebCore::initializeMPEGPlaylistMIMETypes): Added.
     18        (WebCore::initializeMIMETypeRegistry):
     19        (WebCore::MIMETypeRegistry::isMPEGPlaylistMIMEType): Added.
     20        * platform/MIMETypeRegistry.h:
     21        * platform/network/cocoa/WebCoreNSURLSession.mm:
     22        (-[WebCoreNSURLSessionDataTask resource:receivedResponse:]): Add MPEG playlist condition.
     23        (-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:]): Add MPEG playlist condition.
     24
    1252016-08-04  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r195951 r204128  
    147147static HashSet<String, ASCIICaseInsensitiveHash>* supportedNonImageMIMETypes;
    148148static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes;
     149static HashSet<String, ASCIICaseInsensitiveHash>* mpegPlaylistMIMETypes;
    149150static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes;
    150151static HashSet<String, ASCIICaseInsensitiveHash>* pdfAndPostScriptMIMETypes;
     
    302303}
    303304
     305static void initializeMPEGPlaylistMIMETypes()
     306{
     307    const char* const types[] = {
     308        "application/vnd.apple.mpegurl",
     309        "application/mpegurl",
     310        "application/x-mpegurl",
     311        "audio/mpegurl",
     312        "audio/x-mpegurl",
     313        "audio/mpegurl",
     314        "audio/x-mpegurl"
     315    };
     316
     317    for (auto& type : types)
     318        mpegPlaylistMIMETypes->add(type);
     319}
     320
    304321static void initializePDFMIMETypes()
    305322{
     
    456473    initializeSupportedImageMIMETypes();
    457474
     475    mpegPlaylistMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
     476    initializeMPEGPlaylistMIMETypes();
     477
    458478    pdfMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    459479    initializePDFMIMETypes();
     
    552572        || mimeType.startsWith("application/x-java-bean", false)
    553573        || mimeType.startsWith("application/x-java-vm", false);
     574}
     575
     576bool MIMETypeRegistry::isMPEGPlaylistMIMEType(const String& mimeType)
     577{
     578    if (mimeType.isEmpty())
     579        return false;
     580    if (!mpegPlaylistMIMETypes)
     581        initializeMIMETypeRegistry();
     582    return mpegPlaylistMIMETypes->contains(mimeType);
    554583}
    555584
  • trunk/Source/WebCore/platform/MIMETypeRegistry.h

    r195951 r204128  
    7777    static bool isApplicationPluginMIMEType(const String& mimeType);
    7878
     79    // Check to see if a MIME type is one of the MPEG playlists types.
     80    static bool isMPEGPlaylistMIMEType(const String& mimeType);
     81
    7982    // Check to see if a MIME type is one of the common PDF/PS types.
    8083    WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType);
  • trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm

    r203008 r204128  
    3030
    3131#import "CachedResourceRequest.h"
     32#import "MIMETypeRegistry.h"
    3233#import "PlatformMediaResourceLoader.h"
    3334#import "SecurityOrigin.h"
     
    587588        // certain features of CORS, as well as being against the HTTP spec in the case of
    588589        // non-permanent redirects.
    589         auto responseData = response.crossThreadData();
    590         responseData.url = URL(self.currentRequest.URL);
    591         strongResponse = ResourceResponseBase::fromCrossThreadData(WTFMove(responseData)).nsURLResponse();
     590
     591        // Exclude MPEG Playlists since these require the redirected URL as the base URL
     592        // for relative paths.
     593        String mimeType = response.nsURLResponse().MIMEType;
     594        if (mimeType.isEmpty() || mimeType == "application/octet-stream" || mimeType == "text/plain") {
     595            String extension = response.nsURLResponse().URL.pathExtension;
     596            mimeType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
     597
     598        }
     599        if (!MIMETypeRegistry::isMPEGPlaylistMIMEType(mimeType)) {
     600            auto responseData = response.crossThreadData();
     601            responseData.url = URL(self.currentRequest.URL);
     602            strongResponse = ResourceResponseBase::fromCrossThreadData(WTFMove(responseData)).nsURLResponse();
     603        }
    592604    }
    593605
     
    659671    // Do not update the current request if the redirect is temporary; use this
    660672    // current request during responseReceieved: to work around a CoreMedia bug.
    661     if (response.httpStatusCode() != 302 && response.httpStatusCode() != 307)
    662         self.currentRequest = [NSURLRequest requestWithURL:request.url()];
     673
     674    // Exclude MPEG Playlists since these require the redirected URL as the base URL
     675    // for relative paths.
     676    if (response.httpStatusCode() != 302 && response.httpStatusCode() != 307) {
     677        String mimeType = response.nsURLResponse().MIMEType;
     678        if (mimeType.isEmpty() || mimeType == "application/octet-stream" || mimeType == "text/plain") {
     679            String extension = response.nsURLResponse().URL.pathExtension;
     680            mimeType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
     681        }
     682        if (!MIMETypeRegistry::isMPEGPlaylistMIMEType(mimeType))
     683            self.currentRequest = [NSURLRequest requestWithURL:request.url()];
     684    }
    663685
    664686    [self.session updateHasSingleSecurityOrigin:SecurityOrigin::create(request.url())];
Note: See TracChangeset for help on using the changeset viewer.