-
Notifications
You must be signed in to change notification settings - Fork 7.3k
http.ServerResponse#writeFile #1802
Comments
We're still not in a place where we can do it. Some day... |
if this is the API we want we could add this now using a regular file stream and at some point in the future upgrade it to use sendfile(). either way, this won't make 0.6, but we could consider for 0.7. |
I feel the point here is to provide an optimized file-sender. fs.createReadStream(...).pipe(response) is pretty concise already :-) I'm curious as to why one couldn't create a thread-pool routine to invoke sendfile() for a Socket fd today? |
@networkimprov because we don't know when the pending data is actually done being written out. So we want to write the HTTP headers and then do a sendfile() but because the pending writes are not blocking and may be pending or buffered the sendfile syscall may skip ahead of the header writes. |
Right, so alongside (or inside) the Socket's buffer-queue you'd keep a file-queue (with each item's buffer-queue position), so that the Socket knows when to invoke a thread-pool sendfile. And that could be generalized to allow other fd-based modules to write to a Node Socket... |
Hello. What's the status of this a year into the future? |
Pending. |
@joyent/node-coreteam what do we want to do with this one? I agree it will be useful but it's been sitting here forever with no action. Recommend closing. If someone wants this still we can wait for a PR that actually does it. |
Not something that will land in v0.10 or v0.12. Marking as deferred and closing. If this is still something someone wants, then an issue should be opened in nodejs/io.js or nodejs/node |
Provide a writeFile(filename, callback) method of http.ServerResponse (and/or net.Socket) which uses sendfile or splice internally. Would run in the thread pool to avoid blocking.
This was discussed last year and Ry concluded it should wait for the writev patch...
https://groups.google.com/group/nodejs-dev/browse_thread/thread/1461c9ea5e90fc4e/d62fc949de7af66e
Edit: should take a 'noCache' argument, which if true calls posix_fadvise() after each sendfile() call:
The text was updated successfully, but these errors were encountered: