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

Add Partial Content Delivery (+tests) #98

Closed
wants to merge 4 commits into from
Closed

Add Partial Content Delivery (+tests) #98

wants to merge 4 commits into from

Conversation

agersant
Copy link

@agersant agersant commented Jul 8, 2017

This is a follow up to #95. @Cobrand doesn't seem to be active on Github anymore but his pending PR adding partial content responses is very valuable to me. I added unit tests to his code, please let me know if anything else needs to happen for this to be merged!

Cobrand and others added 2 commits February 8, 2017 00:29
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.
@Cobrand
Copy link

Cobrand commented Jul 8, 2017

I am still active on GitHub and I saw your PR on my fork, and I wanted to get to it this week-end but you beat me to it. It's true that lately I haven't as much time as I wished I had, because you know, life'n'stuff.

Anyway I'm grateful that you're taking care of this now, I was starting to feel guilty about not implementing the tests to have this merged.

About the tests themselves, if I were you I would also add some tests for the errors as well. (requesting a byterange were the minimum is higher than the file total, requesting a from -1 in the headers, things like that... but still, great work and thank you again.

@agersant
Copy link
Author

agersant commented Jul 8, 2017

I should have been a bit more patient, I know how busy things can get :c

I'll add a few tests for invalid requests, that's a good point.

Also fixed a edge case bug where a FromTo range ending out of bounds was not treated as a From range (See https://tools.ietf.org/html/rfc7233, section 2.1).
}

/// Panics if the file doesn't exist
pub fn from_path<P: AsRef<Path>, Range>(path: P, range: Range) -> PartialFile

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason this doesn't return a Result<PartialFile, Std::io::Error>?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason was originally that the file existence was already checked beforehand everytime before this method was called (via metadata). However now that I think of it this is pretty racy: if the file is deleted between the check and the file being delivered (which is unlikely but can still happen), then it will panic.

It would be better to return a Result<_, io::Error> there indeed.

@agersant
Copy link
Author

Any update regarding the possibility/timeline of this being merged?

@Emielvanbetsbrugge
Copy link

Emielvanbetsbrugge commented Jul 11, 2018

Hey guys, this works great, we're using this pull request in a video renderer. Should be good to go in. Cheers.

@rockwotj
Copy link

rockwotj commented Aug 7, 2019

Ping!

@rockwotj
Copy link

rockwotj commented Aug 7, 2019

Maybe @untitaker would be willing to review/merge this?

@agersant
Copy link
Author

agersant commented Aug 7, 2019

At this point I would recommend migrating to a web framework that is still maintained.

@rockwotj
Copy link

rockwotj commented Aug 7, 2019

Is this not maintained? A deprecation warning would be nice

@agersant
Copy link
Author

agersant commented Aug 8, 2019

Yeah, Iron hasn't had a commit in a very long time. I think everyone uses Rocket, Actix-Web or some other frameworks now.

joseluisq added a commit to joseluisq/iron-staticfile-middleware that referenced this pull request May 3, 2020
this commit adds partial content delivery support
borrowing @Cobrand's PR iron/staticfile#98
commit motivated by static-web-server/static-web-server#15
@agersant agersant closed this Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants