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

CherryPy ignores "If-Range" HTTP request header #1699

Open
1 of 3 tasks
mpf82 opened this issue Mar 15, 2018 · 0 comments · May be fixed by #1760
Open
1 of 3 tasks

CherryPy ignores "If-Range" HTTP request header #1699

mpf82 opened this issue Mar 15, 2018 · 0 comments · May be fixed by #1760
Labels

Comments

@mpf82
Copy link

mpf82 commented Mar 15, 2018

  • I'm submitting a ...
  • bug report
  • feature request
  • question about the decisions made in the repository
  • What is the current behavior?
    The browser sends a request that contains both RANGE and IF-RANGE values. Note that the If-Range value is way in the past.
Range: bytes=32768-32768
If-Range: Tue, 21 Nov 2017 14:43:11 GMT

However, the CherryPy Server sends back "206 Partial Content" instead of sendong back the file content and status 200.

This violates the If-Range header specification

The If-Range HTTP request header makes a range request conditional: if the condition is fulfilled, the range request will be issued and the server sends back a 206 Partial Content answer with the appropriate body. If the condition is not fulfilled, the full resource is sent back, with a 200 OK status.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem.

The following can be replicated using Chrome or FF:

  • Enable caching in the CherryPy server.
  • Request a page with cached resources (e.g. JS or CSS files)
  • Clear the browser cache.
  • Press F5
  • Only the HTML part is loaded, the "cached" files are missing and will cause a GET http://localhost:45101/jquery.js net::ERR_CONTENT_DECODING_FAILED in the browser console.
  • What is the expected behavior?

The CherryPy server should check if the request contains the If-Range header. And if the condition is not fullfilled, send back the resource and status 200, instead of status 206.

  • What is the motivation / use case for changing the behavior?

This is very annoying, because it prevents the page from loading / refreshing.
You have to do a hard-refresh (Ctrl-F5) to work-around this issue, which cannot be done on mobile devices.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, e.g. stackoverflow, gitter, etc.)

This should probably be fixed in _serve_fileobj().

Request:

grafik

Response:

grafik

@webknjaz webknjaz added the bug label Mar 20, 2018
ian-otto added a commit to ian-otto/cherrypy that referenced this issue Dec 2, 2018
@ian-otto ian-otto linked a pull request Dec 2, 2018 that will close this issue
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants