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

Support for range request queries #526

Merged
merged 22 commits into from Jun 18, 2017

Conversation

Projects
None yet
3 participants
@scouten
Contributor

scouten commented Mar 6, 2017

As mentioned in #523, we would like to serve some light static video content through a Phoenix-based web site and are encountering the issue described in http://stackoverflow.com/questions/36576801/serving-http-range-request-with-phoenix.

This PR adds part of the range request protocol defined in RFC 7233 to Plug.Static.

This implementation supports requests specifying a single range of bytes, which appears to be sufficient to enable video playback in Safari. A client may request multiple byte ranges in the same request, but I am not proposing to implement that in this PR.

Submitting now for preliminary / architectural review. IMHO it is not yet ready for merge.

My to do list (I will probably get back to this later in the week):

  • Double-check implementation against RFC 7233 specs for compliance
  • Review tests for error conditions
  • Check code coverage
  • (Possibly?) Add support for cache mechanisms
Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated

scouten added some commits Mar 6, 2017

Reduce parameters on serve_range/7 (now 5) to make Ebert happy.
Not sure yet how to adjust send_range/7.
@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Apr 21, 2017

Contributor

@josevalim et al: I believe this is ready for review and merge.

Contributor

scouten commented Apr 21, 2017

@josevalim et al: I believe this is ready for review and merge.

@scouten scouten referenced this pull request Apr 28, 2017

Closed

Warnings in Elixir 1.4 #5

Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated test/plug/static_test.exs Outdated
@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Jun 6, 2017

Member

Sorry for the delay in reviewing this. I have added some comments.

Member

josevalim commented Jun 6, 2017

Sorry for the delay in reviewing this. I have added some comments.

Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 12, 2017

Contributor

@josevalim @ericmj this feedback all seems reasonable. I'll work on this over the next couple of weeks and send you a ping when I think it's ready for re-review.

Contributor

scouten commented Jun 12, 2017

@josevalim @ericmj this feedback all seems reasonable. I'll work on this over the next couple of weeks and send you a ping when I think it's ready for re-review.

scouten added some commits Jun 12, 2017

@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 12, 2017

Contributor

@josevalim @ericmj Ping. I think this is ready for re-review.

Contributor

scouten commented Jun 12, 2017

@josevalim @ericmj Ping. I think this is ready for re-review.

Show outdated Hide outdated lib/plug/static.ex Outdated
Show outdated Hide outdated lib/plug/static.ex Outdated
@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Jun 14, 2017

Member

Also paging @TheSquad which implemented a plug that does this.

Member

josevalim commented Jun 14, 2017

Also paging @TheSquad which implemented a plug that does this.

@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 14, 2017

Contributor

FYI this is derived from @TheSquad's plug, but ties in here so as to provide the same guarantees about access, etc., that the rest of plug_static offers.

I'll work on addressing the new feedback from @ericmj in the next couple of days.

Contributor

scouten commented Jun 14, 2017

FYI this is derived from @TheSquad's plug, but ties in here so as to provide the same guarantees about access, etc., that the rest of plug_static offers.

I'll work on addressing the new feedback from @ericmj in the next couple of days.

@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 15, 2017

Contributor

OK, I've added parens and accept-ranges header as requested.

Still looking into caching implementation.

Contributor

scouten commented Jun 15, 2017

OK, I've added parens and accept-ranges header as requested.

Still looking into caching implementation.

@elixir-plug elixir-plug deleted a comment from ebert bot Jun 15, 2017

@elixir-plug elixir-plug deleted a comment from ebert bot Jun 15, 2017

Show outdated Hide outdated lib/plug/static.ex Outdated
@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 17, 2017

Contributor

@josevalim @ericmj Ping. Ready for re-review. There was a fairly substantial refactor since prior versions to make caching work properly with range requests.

Contributor

scouten commented Jun 17, 2017

@josevalim @ericmj Ping. Ready for re-review. There was a fairly substantial refactor since prior versions to make caching work properly with range requests.

@ericmj

ericmj approved these changes Jun 18, 2017

@ericmj ericmj merged commit 01df787 into elixir-plug:master Jun 18, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
ebert Ebert did not find any new or fixed issues.
Details
@ericmj

This comment has been minimized.

Show comment
Hide comment
@ericmj

ericmj Jun 18, 2017

Member

Thank you @scouten! This is a great addition.

Member

ericmj commented Jun 18, 2017

Thank you @scouten! This is a great addition.

@scouten

This comment has been minimized.

Show comment
Hide comment
@scouten

scouten Jun 18, 2017

Contributor

@josevalim @ericmj thanks for your patient reviews and thanks for accepting this contribution!

Contributor

scouten commented Jun 18, 2017

@josevalim @ericmj thanks for your patient reviews and thanks for accepting this contribution!

@scouten scouten deleted the scouten:range-request branch Jun 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment