mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Updated some dependencies and package.json
This commit is contained in:
111
server/node_modules/express/lib/response.js
generated
vendored
Executable file → Normal file
111
server/node_modules/express/lib/response.js
generated
vendored
Executable file → Normal file
@@ -1,5 +1,13 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var contentDisposition = require('content-disposition');
|
||||
@@ -159,15 +167,12 @@ res.send = function send(body) {
|
||||
this.set('Content-Length', len);
|
||||
}
|
||||
|
||||
// method check
|
||||
var isHead = req.method === 'HEAD';
|
||||
|
||||
// ETag support
|
||||
if (len !== undefined && (isHead || req.method === 'GET')) {
|
||||
var etag = app.get('etag fn');
|
||||
if (etag && !this.get('ETag')) {
|
||||
etag = etag(chunk, encoding);
|
||||
etag && this.set('ETag', etag);
|
||||
// populate ETag
|
||||
var etag;
|
||||
var generateETag = len !== undefined && app.get('etag fn');
|
||||
if (typeof generateETag === 'function' && !this.get('ETag')) {
|
||||
if ((etag = generateETag(chunk, encoding))) {
|
||||
this.set('ETag', etag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,14 +187,14 @@ res.send = function send(body) {
|
||||
chunk = '';
|
||||
}
|
||||
|
||||
// skip body for HEAD
|
||||
if (isHead) {
|
||||
if (req.method === 'HEAD') {
|
||||
// skip body for HEAD
|
||||
this.end();
|
||||
} else {
|
||||
// respond
|
||||
this.end(chunk, encoding);
|
||||
}
|
||||
|
||||
// respond
|
||||
this.end(chunk, encoding);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -398,8 +403,8 @@ res.sendFile = function sendFile(path, options, fn) {
|
||||
if (fn) return fn(err);
|
||||
if (err && err.code === 'EISDIR') return next();
|
||||
|
||||
// next() all but aborted errors
|
||||
if (err && err.code !== 'ECONNABORT') {
|
||||
// next() all but write errors
|
||||
if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
@@ -467,8 +472,8 @@ res.sendfile = function(path, options, fn){
|
||||
if (fn) return fn(err);
|
||||
if (err && err.code === 'EISDIR') return next();
|
||||
|
||||
// next() all but aborted errors
|
||||
if (err && err.code !== 'ECONNABORT') {
|
||||
// next() all but write errors
|
||||
if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
@@ -636,6 +641,35 @@ res.attachment = function attachment(filename) {
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Append additional header `field` with value `val`.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
|
||||
* res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
|
||||
* res.append('Warning', '199 Miscellaneous warning');
|
||||
*
|
||||
* @param {String} field
|
||||
* @param {String|Array} val
|
||||
* @return {ServerResponse} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
res.append = function append(field, val) {
|
||||
var prev = this.get(field);
|
||||
var value = val;
|
||||
|
||||
if (prev) {
|
||||
// concat the new and prev vals
|
||||
value = Array.isArray(prev) ? prev.concat(val)
|
||||
: Array.isArray(val) ? [prev].concat(val)
|
||||
: [prev, val];
|
||||
}
|
||||
|
||||
return this.set(field, value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set header `field` to `val`, or pass
|
||||
* an object of header fields.
|
||||
@@ -841,9 +875,9 @@ res.redirect = function redirect(url) {
|
||||
|
||||
if (this.req.method === 'HEAD') {
|
||||
this.end();
|
||||
} else {
|
||||
this.end(body);
|
||||
}
|
||||
|
||||
this.end(body);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -907,6 +941,17 @@ res.render = function(view, options, fn){
|
||||
// pipe the send file stream
|
||||
function sendfile(res, file, options, callback) {
|
||||
var done = false;
|
||||
var streaming;
|
||||
|
||||
// request aborted
|
||||
function onaborted() {
|
||||
if (done) return;
|
||||
done = true;
|
||||
|
||||
var err = new Error('Request aborted');
|
||||
err.code = 'ECONNABORTED';
|
||||
callback(err);
|
||||
}
|
||||
|
||||
// directory
|
||||
function ondirectory() {
|
||||
@@ -932,25 +977,39 @@ function sendfile(res, file, options, callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
// file
|
||||
function onfile() {
|
||||
streaming = false;
|
||||
}
|
||||
|
||||
// finished
|
||||
function onfinish(err) {
|
||||
if (err && err.code === 'ECONNRESET') return onaborted();
|
||||
if (err) return onerror(err);
|
||||
if (done) return;
|
||||
|
||||
setImmediate(function () {
|
||||
if (streaming !== false && !done) {
|
||||
onaborted();
|
||||
return;
|
||||
}
|
||||
|
||||
if (done) return;
|
||||
done = true;
|
||||
|
||||
// response finished before end of file
|
||||
var err = new Error('Request aborted');
|
||||
err.code = 'ECONNABORT';
|
||||
callback(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
// streaming
|
||||
function onstream() {
|
||||
streaming = true;
|
||||
}
|
||||
|
||||
file.on('directory', ondirectory);
|
||||
file.on('end', onend);
|
||||
file.on('error', onerror);
|
||||
file.on('directory', ondirectory);
|
||||
file.on('file', onfile);
|
||||
file.on('stream', onstream);
|
||||
onFinished(res, onfinish);
|
||||
|
||||
if (options.headers) {
|
||||
|
||||
Reference in New Issue
Block a user