# HG changeset patch # User Matthew Gregan # Date 1298259509 -46800 # Node ID d30bc9781cfd23b7cd2dcb8720dd91863c098015 # Parent b5a403b079d3b8c65d37e912de81b7f53c5c2e89 Bug 546700 - Recover gracefully from servers that send Accept-Ranges but don't. r=roc a=roc diff --git a/content/media/nsMediaStream.cpp b/content/media/nsMediaStream.cpp --- a/content/media/nsMediaStream.cpp +++ b/content/media/nsMediaStream.cpp @@ -230,16 +230,19 @@ nsMediaChannelStream::OnStartRequest(nsI } if (mOffset > 0 && responseStatus == HTTP_OK_CODE) { // If we get an OK response but we were seeking, we have to assume // that seeking doesn't work. We also need to tell the cache that // it's getting data for the start of the stream. mCacheStream.NotifyDataStarted(0); mOffset = 0; + + // The server claimed it supported range requests. It lied. + acceptsRanges = PR_FALSE; } else if (mOffset == 0 && (responseStatus == HTTP_OK_CODE || responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) { // We weren't seeking and got a valid response status, // set the length of the content. PRInt32 cl = -1; hc->GetContentLength(&cl); if (cl >= 0) { diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -86,16 +86,17 @@ _TEST_FILES = \ seek6.js \ seek7.js \ seek8.js \ seek9.js \ seek10.js \ seek11.js \ seek12.js \ seek13.js \ + seekLies.sjs \ test_access_control.html \ test_audio1.html \ test_audio2.html \ test_autoplay.html \ test_autoplay_contentEditable.html \ test_buffered.html \ test_bug448534.html \ test_bug463162.xhtml \ @@ -130,16 +131,17 @@ _TEST_FILES = \ test_preload_actions.html \ test_preload_attribute.html \ test_progress.html \ test_reactivate.html \ test_readyState.html \ test_replay_metadata.html \ test_seek.html \ test_seek2.html \ + test_seekLies.html \ test_seek_out_of_range.html \ test_source.html \ test_source_write.html \ test_standalone.html \ test_timeupdate_small_files.html \ test_volume.html \ test_video_to_canvas.html \ use_large_cache.js \ diff --git a/content/media/test/seekLies.sjs b/content/media/test/seekLies.sjs new file mode 100644 --- /dev/null +++ b/content/media/test/seekLies.sjs @@ -0,0 +1,23 @@ +function handleRequest(request, response) +{ + var file = Components.classes["@mozilla.org/file/directory_service;1"]. + getService(Components.interfaces.nsIProperties). + get("CurWorkD", Components.interfaces.nsILocalFile); + var fis = Components.classes['@mozilla.org/network/file-input-stream;1']. + createInstance(Components.interfaces.nsIFileInputStream); + var bis = Components.classes["@mozilla.org/binaryinputstream;1"]. + createInstance(Components.interfaces.nsIBinaryInputStream); + var paths = "tests/content/media/test/seek.ogv"; + var split = paths.split("/"); + for(var i = 0; i < split.length; ++i) { + file.append(split[i]); + } + fis.init(file, -1, -1, false); + bis.setInputStream(fis); + var bytes = bis.readBytes(bis.available()); + response.setHeader("Content-Length", ""+bytes.length, false); + response.setHeader("Content-Type", "video/ogg", false); + response.setHeader("Accept-Ranges", "bytes", false); + response.write(bytes, bytes.length); + bis.close(); +} diff --git a/content/media/test/test_seekLies.html b/content/media/test/test_seekLies.html new file mode 100644 --- /dev/null +++ b/content/media/test/test_seekLies.html @@ -0,0 +1,27 @@ + + + + Media test: server lies about range requests + + + + + +
+
+
+ + +