Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range header is not send #1164

Closed
vardius opened this issue Jun 22, 2017 · 2 comments
Closed

Range header is not send #1164

vardius opened this issue Jun 22, 2017 · 2 comments

Comments

@vardius
Copy link

vardius commented Jun 22, 2017

Hi I have simple service worker, but my Range header is not being send even thought i can log it on request object.

    self.addEventListener('fetch', async function(event) {
        if (event.request.headers.get("range")) {
          const response = await fetch(event.request.clone());
    
          return  event.respondWith(this.getPartialResponse(event.request, response));
        }
    
        return  event.respondWith(fetch(event.request));
    }
    
    async getPartialResponse(req, res) {
      const pos = Number(/^bytes\=(\d )\-$/g.exec(req.headers.get("range"))[1]);
      const ab = await res.arrayBuffer();
      const headers = new Headers(res.headers);
    
      headers.append("Content-Range", `bytes ${pos}-${ab.byteLength - 1}/${ab.byteLength}`);
      headers.append("Content-Length", ab.byteLength - pos   1);
    
      return new Response(ab.slice(pos), {
        status: 206,
        statusText: "Partial Content",
        headers
      });
    }

Here you can see request one catched by service worker and the second one send to the api where you can notice the Range header is missing. Why ? My browser: Chrome/59.0.3071.104

console 1
console 2

@jakearchibald
Copy link
Contributor

We're tackling this at whatwg/fetch#144

@AndySpider
Copy link

@vardius, Hi, just be interested, may off the topic, what's the browser you were using? And how did you send the movie.mp4 request?
I have some code run in Chrome, and I see Chrome never sends the "Range" header to my service worker... No idea how to make Chrome send request with the "Range" header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants