Content-Range working in Safari but not in Chrome












0














I'm streaming audio files from a Node.js Express server with Content-Range headers plus no caching headers. This works ok in latest Safari instead, but it does not in Chrome.



While when streaming the full audio file with HTTP 200, my headers were



{ 'Content-Length': 4724126,
'Content-Type': 'audio/mpeg',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
Expires: 0,
Pragma: 'no-cache',
'Cache-Control': 'no-cache, no-store, must-revalidate' }


and it works on both Chrome and Safari <audio> tag.



When streaming partial contents with HTTP 206 the headers were



{ 'Content-Length': 4724126,
'Content-Type': 'audio/mpeg',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
Expires: 0,
Pragma: 'no-cache',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Accept-Ranges': 'bytes',
'Content-Range': 'bytes 120515-240260/4724126' }


This led to an error of the Chrome page where the <audio> or <video> tag was.



Even the embedded media tag created by Chrome when using the streaming url right in the browser it is not working, and led to this



enter image description here



The audio file is served reading a local file and creating a file read stream via Node.js the createReadStream api:



var file = fs.createReadStream(path, {start: range[0], end: range[1]});


I have posted the code for the server here.



[UPDATE]



It turns not that Chrome is more strict about Range and Content-Range requests/responses. So any Content-Range response must have a Range previous request. The typical case is scrubbing a player bar to the second S. The api will send a "Range" request, the server will respond with a "Content-Range" header. In my case I was sending a Content-Range response over an ordinary request without "Range". Safari works because is more street-html complaint i.e. it does not strictly require a "Range" request before a "Content-Range" response. So, I removed the "Content-Range" header from my response, and not it works.
End of the story (!).



To follow up this issue I have posted in Chromium net-dev forum too in Chrome bad Range header: Range: bytes=0-










share|improve this question





























    0














    I'm streaming audio files from a Node.js Express server with Content-Range headers plus no caching headers. This works ok in latest Safari instead, but it does not in Chrome.



    While when streaming the full audio file with HTTP 200, my headers were



    { 'Content-Length': 4724126,
    'Content-Type': 'audio/mpeg',
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
    'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
    Expires: 0,
    Pragma: 'no-cache',
    'Cache-Control': 'no-cache, no-store, must-revalidate' }


    and it works on both Chrome and Safari <audio> tag.



    When streaming partial contents with HTTP 206 the headers were



    { 'Content-Length': 4724126,
    'Content-Type': 'audio/mpeg',
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
    'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
    Expires: 0,
    Pragma: 'no-cache',
    'Cache-Control': 'no-cache, no-store, must-revalidate',
    'Accept-Ranges': 'bytes',
    'Content-Range': 'bytes 120515-240260/4724126' }


    This led to an error of the Chrome page where the <audio> or <video> tag was.



    Even the embedded media tag created by Chrome when using the streaming url right in the browser it is not working, and led to this



    enter image description here



    The audio file is served reading a local file and creating a file read stream via Node.js the createReadStream api:



    var file = fs.createReadStream(path, {start: range[0], end: range[1]});


    I have posted the code for the server here.



    [UPDATE]



    It turns not that Chrome is more strict about Range and Content-Range requests/responses. So any Content-Range response must have a Range previous request. The typical case is scrubbing a player bar to the second S. The api will send a "Range" request, the server will respond with a "Content-Range" header. In my case I was sending a Content-Range response over an ordinary request without "Range". Safari works because is more street-html complaint i.e. it does not strictly require a "Range" request before a "Content-Range" response. So, I removed the "Content-Range" header from my response, and not it works.
    End of the story (!).



    To follow up this issue I have posted in Chromium net-dev forum too in Chrome bad Range header: Range: bytes=0-










    share|improve this question



























      0












      0








      0


      1





      I'm streaming audio files from a Node.js Express server with Content-Range headers plus no caching headers. This works ok in latest Safari instead, but it does not in Chrome.



      While when streaming the full audio file with HTTP 200, my headers were



      { 'Content-Length': 4724126,
      'Content-Type': 'audio/mpeg',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
      'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
      Expires: 0,
      Pragma: 'no-cache',
      'Cache-Control': 'no-cache, no-store, must-revalidate' }


      and it works on both Chrome and Safari <audio> tag.



      When streaming partial contents with HTTP 206 the headers were



      { 'Content-Length': 4724126,
      'Content-Type': 'audio/mpeg',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
      'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
      Expires: 0,
      Pragma: 'no-cache',
      'Cache-Control': 'no-cache, no-store, must-revalidate',
      'Accept-Ranges': 'bytes',
      'Content-Range': 'bytes 120515-240260/4724126' }


      This led to an error of the Chrome page where the <audio> or <video> tag was.



      Even the embedded media tag created by Chrome when using the streaming url right in the browser it is not working, and led to this



      enter image description here



      The audio file is served reading a local file and creating a file read stream via Node.js the createReadStream api:



      var file = fs.createReadStream(path, {start: range[0], end: range[1]});


      I have posted the code for the server here.



      [UPDATE]



      It turns not that Chrome is more strict about Range and Content-Range requests/responses. So any Content-Range response must have a Range previous request. The typical case is scrubbing a player bar to the second S. The api will send a "Range" request, the server will respond with a "Content-Range" header. In my case I was sending a Content-Range response over an ordinary request without "Range". Safari works because is more street-html complaint i.e. it does not strictly require a "Range" request before a "Content-Range" response. So, I removed the "Content-Range" header from my response, and not it works.
      End of the story (!).



      To follow up this issue I have posted in Chromium net-dev forum too in Chrome bad Range header: Range: bytes=0-










      share|improve this question















      I'm streaming audio files from a Node.js Express server with Content-Range headers plus no caching headers. This works ok in latest Safari instead, but it does not in Chrome.



      While when streaming the full audio file with HTTP 200, my headers were



      { 'Content-Length': 4724126,
      'Content-Type': 'audio/mpeg',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
      'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
      Expires: 0,
      Pragma: 'no-cache',
      'Cache-Control': 'no-cache, no-store, must-revalidate' }


      and it works on both Chrome and Safari <audio> tag.



      When streaming partial contents with HTTP 206 the headers were



      { 'Content-Length': 4724126,
      'Content-Type': 'audio/mpeg',
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
      'Access-Control-Allow-Headers': 'POST, GET, OPTIONS',
      Expires: 0,
      Pragma: 'no-cache',
      'Cache-Control': 'no-cache, no-store, must-revalidate',
      'Accept-Ranges': 'bytes',
      'Content-Range': 'bytes 120515-240260/4724126' }


      This led to an error of the Chrome page where the <audio> or <video> tag was.



      Even the embedded media tag created by Chrome when using the streaming url right in the browser it is not working, and led to this



      enter image description here



      The audio file is served reading a local file and creating a file read stream via Node.js the createReadStream api:



      var file = fs.createReadStream(path, {start: range[0], end: range[1]});


      I have posted the code for the server here.



      [UPDATE]



      It turns not that Chrome is more strict about Range and Content-Range requests/responses. So any Content-Range response must have a Range previous request. The typical case is scrubbing a player bar to the second S. The api will send a "Range" request, the server will respond with a "Content-Range" header. In my case I was sending a Content-Range response over an ordinary request without "Range". Safari works because is more street-html complaint i.e. it does not strictly require a "Range" request before a "Content-Range" response. So, I removed the "Content-Range" header from my response, and not it works.
      End of the story (!).



      To follow up this issue I have posted in Chromium net-dev forum too in Chrome bad Range header: Range: bytes=0-







      javascript google-chrome audio-streaming http-content-range






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 9:10

























      asked Nov 12 '18 at 9:59









      loretoparisi

      7,60354771




      7,60354771
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259737%2fcontent-range-working-in-safari-but-not-in-chrome%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259737%2fcontent-range-working-in-safari-but-not-in-chrome%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Hercules Kyvelos

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud