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

Byte-Range Support? #84

Open
jcready opened this issue Jun 10, 2017 · 10 comments
Open

Byte-Range Support? #84

jcready opened this issue Jun 10, 2017 · 10 comments

Comments

@jcready
Copy link

jcready commented Jun 10, 2017

Are there plans to add byte-range support to this? Similar to the send module that express uses?

@haoxins
Copy link
Member

haoxins commented Jun 11, 2017

@jcready
Copy link
Author

jcready commented Jun 11, 2017

Ahh, thanks @coderhaoxin. However doesn't this mean that if a client sent a request for a very large file (let's say 1GB) with a Range: 0-1 header that, while the client would correctly only get the first 2 bytes, the server would continue reading from disk and emitting 'data' events until the entire 1GB file had been read? And the file descriptor would remain open long after the request/response transaction had been completed?

@jcready
Copy link
Author

jcready commented Jun 11, 2017

Similarly, if a client sent a request with Range: -1 the read stream created by this module would have to read the entire file before finally being able to send the last byte.

@haoxins
Copy link
Member

haoxins commented Jun 12, 2017

  1. I don't serve files directly on my node.js server (in production). They are served via CDN :) 😢
  2. But just as you said, I think it's reasonable to add range support in koa-send, just as pillarjs/send
  3. I'm also thinking about the possibility to dep pillarjs/send :)

@PFWhite
Copy link

PFWhite commented Apr 17, 2018

Anyone working on this? I am currently using koa-send and need byte-range support. I'd be willing to contribute to this since I'll need to write it anyway.

@haoxins
Copy link
Member

haoxins commented Apr 18, 2018

@PFWhite PR welcome :)

@PFWhite
Copy link

PFWhite commented Apr 19, 2018

@coderhaoxin PR up!

@jcready
Copy link
Author

jcready commented Apr 19, 2018

Why not simply depend on pillarjs/send?

@PFWhite
Copy link

PFWhite commented Apr 19, 2018

I'm not familiar with the library. I instead read the spec, wrote the tests and implemented the feature.

Also I recently wasted 8 hours tracking down an issue with a body parsing Middleware that didn't couldn't read multipart form data without a content length so I had to write one with busboy.

Here I knew what I needed, how to do it, how long it would take, didn't want another dependency, and saw that people wanted this too so why not write it and give back to Koa-send.

@Meleeman01
Copy link

#121 i see there was a pr here that hasn't fixed its merge conflicts, i could really use this for my own application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants