Socket
Socket
Sign inDemoInstall

ecstatic

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecstatic - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

2019/04/14 Version 4.0.2
- Add dependency for is-finished library
- Fixes for edge cases around closed/finished streams
2019/04/12 Version 4.0.1

@@ -2,0 +6,0 @@ - Fix file descriptor leak from upstream response closing

38

lib/ecstatic.js

@@ -15,2 +15,3 @@ #! /usr/bin/env node

const optsParser = require('./ecstatic/opts');
const onFinished = require('on-finished');

@@ -245,2 +246,6 @@ let ecstatic = null;

function serve(stat) {
if (onFinished.isFinished(res)) {
return;
}
// Do a MIME lookup, fall back to octet-stream and handle gzip

@@ -256,3 +261,2 @@ // and brotli special case.

let cacheControl = cache;
let stream = null;
if (contentType) {

@@ -293,3 +297,2 @@ charSet = mime.lookupCharset(contentType);

const chunksize = (end - start) + 1;
let fstream = null;

@@ -301,9 +304,2 @@ if (start > end || isNaN(start) || isNaN(end)) {

fstream = fs.createReadStream(file, { start, end });
fstream.on('error', (err) => {
status['500'](res, next, { error: err });
});
res.on('close', () => {
fstream.destroy();
});
res.writeHead(206, {

@@ -318,3 +314,12 @@ 'Content-Range': `bytes ${start}-${end}/${total}`,

});
fstream.pipe(res);
const stream = fs
.createReadStream(file, { start, end })
.on('error', (err) => {
status['500'](res, next, { error: err });
})
.pipe(res);
onFinished(res, () => {
stream.destroy();
});
return;

@@ -347,7 +352,10 @@ }

stream = fs.createReadStream(file);
stream.pipe(res);
stream.on('error', (err) => {
status['500'](res, next, { error: err });
const stream = fs
.createReadStream(file)
.on('error', (err) => {
status['500'](res, next, { error: err });
})
.pipe(res);
onFinished(res, () => {
stream.destroy();
});

@@ -354,0 +362,0 @@ res.on('close', () => {

@@ -5,3 +5,3 @@ {

"description": "A simple static file server middleware",
"version": "4.0.1",
"version": "4.0.2",
"homepage": "https://github.com/jfhbrook/node-ecstatic",

@@ -33,2 +33,3 @@ "repository": {

"minimist": "^1.1.0",
"on-finished": "^2.3.0",
"url-join": "^4.0.0"

@@ -35,0 +36,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc