Skip to content
Send a file back as a HTTP response with support for range queries etc.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore first commit Aug 13, 2019
LICENSE first commit Aug 13, 2019
README.md first commit Aug 13, 2019
example.js first commit Aug 13, 2019
index.js
package.json 1.0.0 Aug 13, 2019

README.md

http-file-response

Send a file back as a HTTP response with support for range queries etc.

npm install http-file-response

Usage

const onfile = require('http-file-response')

http.createServer(function (req, res) {
  onfile('some-file.html', req, res)
})

API

onfile(filename, req, res, [options])

Options include:

{
  mime: '...', // optionally set the mimetype, defaults to infering it from the name
  fs: ... // optionally pass in your own fs impl to use
}

License

MIT

You can’t perform that action at this time.