-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add Partial Content Delivery #95
Conversation
This commits adds Partial Content Delivery, as asked in issue iron#93. This enables the "Accept-Ranges" header on all files delivered via static. It is possible to ask only a certain portion of bytes like explicitely described in RFC 7233. Of the 3 ways to ask for a range of bytes (byte x to byte y, everything from byte x to end of file, last y bytes from end of file), every one of them is implemented, but if a request is to ask multi ranges in a same request, this implementation will only account the first range.
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.
One small comment, also please add tests.
|
||
}; | ||
if let Some(range) = range { | ||
let content_range = ContentRange(ContentRangeSpec::Bytes { |
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.
Setting content range can be done at the very beginning to deduplicate the code here. If the file length is None
we can then set RangeNotSatisfiable
and return early.
Anything we can do to help support you in landing this PR? |
If someone could help me on the test part of this PR, that's be great. I don't ask for anyone else to implement the tests themselves (although that'd be great), but if someone could give me a hint as to what to use in |
Right, so I think you should be able to use |
It looks like #98 (comment) follows up on this so closing in favor of it. |
This commits adds Partial Content Delivery, as asked in issue #93. This
enables the "Accept-Ranges" header on all files delivered via
static. It is possible to ask only a certain portion of bytes like
explicitely described in RFC 7233. Of the 3 ways to ask for a range of
bytes (byte x to byte y, everything from byte x to end of file, last y
bytes from end of file), every one of them is implemented, but if a
request is to ask multi ranges in a same request, this implementation
will only account the first range.
---- end of commit ----
Quite a big PR I have here, I hope it's not too much hassle. If you think there are better ways to structure my code, please tell me I'll fix that right away ! What is good coding to me might not be for iron, and I'm fine with that !
So basically it closes partially #93 . It works for a single range, but multiple ranges are not yet supported (that's why it doesn't close #93 totally in my opinion). Video seeking works fine though, in firefox, chrome or mpv, or whatever.
I'm missing tests as well, and I'd like support on that part. I must say that I'm not familiar with
iron_test
and your way of testing, and I don't really know what to test either. So if someone could comment on that part, that'd be nice.This change is