Socket
Socket
Sign inDemoInstall

send

Package Overview
Dependencies
5
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.1.0

5

History.md
0.1.0 / 2012-08-25
==================
* add options parameter to send() that is passed to fs.createReadStream() [kanongil]
0.0.4 / 2012-08-16

@@ -3,0 +8,0 @@ ==================

31

lib/send.js

@@ -36,2 +36,3 @@

* @param {String} path
* @param {Object} options
* @return {SendStream}

@@ -41,4 +42,4 @@ * @api public

function send(req, path) {
return new SendStream(req, path);
function send(req, path, options) {
return new SendStream(req, path, options);
}

@@ -58,9 +59,11 @@

* @param {String} path
* @param {Object} options
* @api private
*/
function SendStream(req, path) {
function SendStream(req, path, options) {
var self = this;
this.req = req;
this.path = path;
this.options = options || {};
this.maxage(0);

@@ -336,3 +339,3 @@ this.hidden(false);

SendStream.prototype.send = function(path, stat){
var options = {};
var options = this.options;
var len = stat.size;

@@ -342,2 +345,3 @@ var res = this.res;

var ranges = req.headers.range;
var offset = options.start || 0;

@@ -357,2 +361,9 @@ // set header fields

// adjust len to start/end options
len = Math.max(0, len - offset);
if (options.end !== undefined) {
var bytes = options.end - offset + 1;
if (len > bytes) len = bytes;
}
// Range support

@@ -370,14 +381,14 @@ if (ranges) {

if (-2 != ranges) {
options.start = ranges[0].start;
options.end = ranges[0].end;
options.start = offset + ranges[0].start;
options.end = offset + ranges[0].end;
// Content-Range
len = options.end - options.start + 1;
res.statusCode = 206;
res.setHeader('Content-Range', 'bytes '
+ options.start
+ ranges[0].start
+ '-'
+ options.end
+ ranges[0].end
+ '/'
+ stat.size);
+ len);
len = options.end - options.start + 1;
}

@@ -384,0 +395,0 @@ }

{
"name": "send",
"version": "0.0.4",
"version": "0.1.0",
"description": "Better streaming static file server with Range and conditional-GET support",

@@ -5,0 +5,0 @@ "keywords": ["static", "file", "server"],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc