send
send copied to clipboard
Byte-Range Support?
Are there plans to add byte-range support to this? Similar to the send module that express uses?
@jcready try https://github.com/koajs/koa-range :)
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?
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.
- I don't serve files directly on my node.js server (in production). They are served via CDN :) 😢
- But just as you said, I think it's reasonable to add
range
support inkoa-send
, just aspillarjs/send
- I'm also thinking about the possibility to dep
pillarjs/send
:)
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.
@PFWhite PR welcome :)
@coderhaoxin PR up!
Why not simply depend on pillarjs/send
?
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.
https://github.com/koajs/send/pull/121 i see there was a pr here that hasn't fixed its merge conflicts, i could really use this for my own application