Title: [204169] branches/safari-602-branch

Diff

Modified: branches/safari-602-branch/LayoutTests/ChangeLog (204168 => 204169)


--- branches/safari-602-branch/LayoutTests/ChangeLog	2016-08-05 15:39:10 UTC (rev 204168)
+++ branches/safari-602-branch/LayoutTests/ChangeLog	2016-08-05 16:20:21 UTC (rev 204169)
@@ -1,3 +1,20 @@
+2016-08-05  Babak Shafiei  <[email protected]>
+
+        Merge r204128. rdar://problem/27592694
+
+    2016-08-04  Jeremy Jones  <[email protected]>
+
+            Temporary redirected m3u8 streaming stopped working.
+            https://bugs.webkit.org/show_bug.cgi?id=160472
+            rdar://problem/27592694
+
+            Reviewed by Alex Christensen.
+
+            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.
+
 2016-08-04  Babak Shafiei  <[email protected]>
 
         Rollout r204132. rdar://problem/27685273

Added: branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect-expected.txt (0 => 204169)


--- branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect-expected.txt	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect-expected.txt	2016-08-05 16:20:21 UTC (rev 204169)
@@ -0,0 +1,4 @@
+
+load metadata OK
+END OF TEST
+

Added: branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect.html (0 => 204169)


--- branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect.html	                        (rev 0)
+++ branches/safari-602-branch/LayoutTests/http/tests/media/hls/hls-redirect.html	2016-08-05 16:20:21 UTC (rev 204169)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<video src="" _onloadedmetadata_="logResult(true, 'load metadata'); endTest()" _onerror_="failTest('load error')"></video>
+</body>
+</html>

Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (204168 => 204169)


--- branches/safari-602-branch/Source/WebCore/ChangeLog	2016-08-05 15:39:10 UTC (rev 204168)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog	2016-08-05 16:20:21 UTC (rev 204169)
@@ -1,3 +1,31 @@
+2016-08-05  Babak Shafiei  <[email protected]>
+
+        Merge r204128. rdar://problem/27592694
+
+    2016-08-04  Jeremy Jones  <[email protected]>
+
+            Temporary redirected m3u8 streaming stopped working.
+            https://bugs.webkit.org/show_bug.cgi?id=160472
+            rdar://problem/27592694
+
+            Reviewed by Alex Christensen.
+
+            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.
+
 2016-08-04  Babak Shafiei  <[email protected]>
 
         Rollout r204132. rdar://problem/27685273

Modified: branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.cpp (204168 => 204169)


--- branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.cpp	2016-08-05 15:39:10 UTC (rev 204168)
+++ branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.cpp	2016-08-05 16:20:21 UTC (rev 204169)
@@ -146,6 +146,7 @@
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedJavaScriptMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedNonImageMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes;
+static HashSet<String, ASCIICaseInsensitiveHash>* mpegPlaylistMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* pdfAndPostScriptMIMETypes;
 static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes;
@@ -301,6 +302,22 @@
         supportedJavaScriptMIMETypes->add(type);
 }
 
+static void initializeMPEGPlaylistMIMETypes()
+{
+    const char* const types[] = {
+        "application/vnd.apple.mpegurl",
+        "application/mpegurl",
+        "application/x-mpegurl",
+        "audio/mpegurl",
+        "audio/x-mpegurl",
+        "audio/mpegurl",
+        "audio/x-mpegurl"
+    };
+
+    for (auto& type : types)
+        mpegPlaylistMIMETypes->add(type);
+}
+
 static void initializePDFMIMETypes()
 {
     const char* const types[] = {
@@ -455,6 +472,9 @@
     supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
     initializeSupportedImageMIMETypes();
 
+    mpegPlaylistMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
+    initializeMPEGPlaylistMIMETypes();
+
     pdfMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
     initializePDFMIMETypes();
 
@@ -553,6 +573,15 @@
         || mimeType.startsWith("application/x-java-vm", false);
 }
 
+bool MIMETypeRegistry::isMPEGPlaylistMIMEType(const String& mimeType)
+{
+    if (mimeType.isEmpty())
+        return false;
+    if (!mpegPlaylistMIMETypes)
+        initializeMIMETypeRegistry();
+    return mpegPlaylistMIMETypes->contains(mimeType);
+}
+
 bool MIMETypeRegistry::isPDFOrPostScriptMIMEType(const String& mimeType)
 {
     if (mimeType.isEmpty())

Modified: branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.h (204168 => 204169)


--- branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.h	2016-08-05 15:39:10 UTC (rev 204168)
+++ branches/safari-602-branch/Source/WebCore/platform/MIMETypeRegistry.h	2016-08-05 16:20:21 UTC (rev 204169)
@@ -76,6 +76,9 @@
     // Check to see if a MIME type is a plugin implemented by the browser.
     static bool isApplicationPluginMIMEType(const String& mimeType);
 
+    // Check to see if a MIME type is one of the MPEG playlists types.
+    static bool isMPEGPlaylistMIMEType(const String& mimeType);
+
     // Check to see if a MIME type is one of the common PDF/PS types.
     WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType);
     static bool isPDFMIMEType(const String& mimeType);

Modified: branches/safari-602-branch/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm (204168 => 204169)


--- branches/safari-602-branch/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm	2016-08-05 15:39:10 UTC (rev 204168)
+++ branches/safari-602-branch/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm	2016-08-05 16:20:21 UTC (rev 204169)
@@ -29,6 +29,7 @@
 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 
 #import "CachedResourceRequest.h"
+#import "MIMETypeRegistry.h"
 #import "PlatformMediaResourceLoader.h"
 #import "SecurityOrigin.h"
 #import "SubresourceLoader.h"
@@ -586,9 +587,20 @@
         // and use that URL for all future requests for the same piece of media. This breaks
         // certain features of CORS, as well as being against the HTTP spec in the case of
         // non-permanent redirects.
-        auto responseData = response.crossThreadData();
-        responseData.url = ""
-        strongResponse = ResourceResponseBase::fromCrossThreadData(WTFMove(responseData)).nsURLResponse();
+
+        // Exclude MPEG Playlists since these require the redirected URL as the base URL
+        // for relative paths.
+        String mimeType = response.nsURLResponse().MIMEType;
+        if (mimeType.isEmpty() || mimeType == "application/octet-stream" || mimeType == "text/plain") {
+            String extension = response.nsURLResponse().URL.pathExtension;
+            mimeType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
+
+        }
+        if (!MIMETypeRegistry::isMPEGPlaylistMIMEType(mimeType)) {
+            auto responseData = response.crossThreadData();
+            responseData.url = ""
+            strongResponse = ResourceResponseBase::fromCrossThreadData(WTFMove(responseData)).nsURLResponse();
+        }
     }
 
     RetainPtr<WebCoreNSURLSessionDataTask> strongSelf { self };
@@ -658,9 +670,19 @@
     // FIXME(<rdar://problem/27000361>):
     // Do not update the current request if the redirect is temporary; use this
     // current request during responseReceieved: to work around a CoreMedia bug.
-    if (response.httpStatusCode() != 302 && response.httpStatusCode() != 307)
-        self.currentRequest = [NSURLRequest requestWithURL:request.url()];
 
+    // Exclude MPEG Playlists since these require the redirected URL as the base URL
+    // for relative paths.
+    if (response.httpStatusCode() != 302 && response.httpStatusCode() != 307) {
+        String mimeType = response.nsURLResponse().MIMEType;
+        if (mimeType.isEmpty() || mimeType == "application/octet-stream" || mimeType == "text/plain") {
+            String extension = response.nsURLResponse().URL.pathExtension;
+            mimeType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
+        }
+        if (!MIMETypeRegistry::isMPEGPlaylistMIMEType(mimeType))
+            self.currentRequest = [NSURLRequest requestWithURL:request.url()];
+    }
+
     [self.session updateHasSingleSecurityOrigin:SecurityOrigin::create(request.url())];
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to