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

Range request handling #40

Merged
merged 2 commits into from
Aug 14, 2018
Merged

Range request handling #40

merged 2 commits into from
Aug 14, 2018

Conversation

mischnic
Copy link
Contributor

@mischnic mischnic commented Jul 27, 2018

I hope this isn't considered out of scope...
This can be tested in the "real world" by browsing to a video file in Safari (didn't work before)

Should these features be implemented as well?

  • Handling of multiple ranges (with a multipart response, currently only the first range is used)
  • the If-Range header

This change could be considered breaking:

--- a/test/integration.js
+++ b/test/integration.js
@@ -869,9 +869,9 @@ test('set `createReadStream` handler to async function', async t => {

        // eslint-disable-next-line no-undefined
        const url = await getUrl(undefined, {
-               createReadStream: async file => {
+               createReadStream: async (file, opts) => {
                        await sleep(2000);
-                       return fs.createReadStream(file);
+                       return fs.createReadStream(file, opts);
                }
        });

Came up in https://github.com/vercel/serve/issues/447

@mischnic mischnic changed the title Initial range request handling Range request handling Jul 27, 2018
@codecov
Copy link

codecov bot commented Jul 27, 2018

Codecov Report

Merging #40 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #40   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         289    303   +14     
=====================================
+ Hits          289    303   +14
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae228f3...e36219b. Read the comment docs.

@leo
Copy link
Contributor

leo commented Aug 13, 2018

What a great PR, thank you!

How is your change to createReadStream a breaking change though? You only added yet another argument for the function call...? 😊

@leo leo self-requested a review August 13, 2018 17:36
@leo leo added the enhancement New feature or request label Aug 13, 2018
@leo
Copy link
Contributor

leo commented Aug 13, 2018

By the way, supporting these two would be perfect! ☺️

  • Handling of multiple ranges (with a multipart response, currently only the first range is used)
  • The If-Range header

Thank you so much!

@leo
Copy link
Contributor

leo commented Aug 14, 2018

Oh, now I understand why it's a breaking change. Thank you!

Let's add the other two features in a future release, if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants