Serve content with support for HTTP conditionals and range requests #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces new utilities to serve content with support for HTTP conditionals as defined in RFC7232. It will allow to return
304 Not Modified
(for instance) and handle HTTP Range requests (RFC7233) transparently.Motivation and Context
Implementing RFC7232 and RFC7233 is not trivial: I believe it should be implemented at
Tide
level instead of leaving the users implementing it themselves. At the time I checked a few weeks agoRocket
,warp
andactix
all had limited (if any) support for such conditional requests (this might have changed). Support for conditional requests is provided by Go's standard http library.This will help closing #63. Also the current implementation of
tide::Route::serve_dir
could benefit from it to handle last modification date and range requests.I am already running a full implementation in production to serve a bunch of video files for internal use (building a media center for home).
This draft PR depends on changes that are not yet released (some not even merged) in http-types, see dependencies section below. I will update this PR as much as the situation evolves on
http-types
side. I will then commit the implementation, testing and more documentation.Finally i will move out of draft status once everything is released on
http-types
side and implementation, tests and docs completed.For now I am requesting comments for interest in such feature within
Tide
or if you prefer that I release this in an external crate. Also I would like you comments on the API, please.Thanks in advance !
Cheers.
Types of changes
Checklist:
Dependencies:
conditional::{IfModifiedSince, IfUnmodifiedSince, LastModified}
http-types#222 to be mergedconditional::{IfMatch, IfNoneMatch}
http-types#224 to be mergedrange
submodule http-types#180 to be merged