-
Notifications
You must be signed in to change notification settings - Fork 321
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
Serve content with support for HTTP conditionals and range requests #687
Conversation
This will allow to separate non related utilities in the future.
Allows to serve content handling HTTP conditional requests as defined in RFC7232.
I think if we have this, then I am not sure if that would be confusing or not, given most of the other things there represent http headers directly, but it feels like the correct place. |
This is indeed an open question. It could be renamed in something like Looking at what Go does they just allow a time in their Otherwise I have no strong opinion about it. |
|
||
use crate::{Request, Response, Result, StatusCode}; | ||
|
||
/// A HTTP ressource modification state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A HTTP ressource modification state. | |
/// A HTTP resource modification state. |
And other uses of the word
I might change my opinion here. When you look at the |
Hi, I’m interested that conditional headers in tide framework. I tried to implements the middleware which can only verify about If-None-Match and content ETag. if they match, it returns the 304 NotModified. serve_file directive must know about file modified information through from_file_with_path of http-types https://docs.rs/async-std/0.99.12/async_std/fs/struct.Metadata.html#method.modified It is possible to be use this. Although, it has not implemented about this yet. |
I am closing this PR as I am not using/working on tide anymore and will thus not be able to work on this further on. |
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