Started adding slash commands, doesn't work though

This commit is contained in:
ION606
2022-09-26 15:41:20 +00:00
parent b6495eb886
commit ec4c1200d5
2214 changed files with 159174 additions and 42761 deletions
Generated Vendored
+37 -27
View File
@@ -1,7 +1,7 @@
/*!
* send
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* Copyright(c) 2014-2022 Douglas Christopher Wilson
* MIT Licensed
*/
@@ -267,13 +267,11 @@ SendStream.prototype.maxage = deprecate.function(function maxage (maxAge) {
SendStream.prototype.error = function error (status, err) {
// emit if listeners instead of responding
if (hasListeners(this, 'error')) {
return this.emit('error', createError(status, err, {
expose: false
}))
return this.emit('error', createHttpError(status, err))
}
var res = this.res
var msg = statuses[status] || String(status)
var msg = statuses.message[status] || String(status)
var doc = createHtmlDocument('Error', escapeHtml(msg))
// clear existing headers
@@ -349,21 +347,19 @@ SendStream.prototype.isPreconditionFailure = function isPreconditionFailure () {
}
/**
* Strip content-* header fields.
* Strip various content header fields for a change in entity.
*
* @private
*/
SendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields () {
var res = this.res
var headers = getHeaderNames(res)
for (var i = 0; i < headers.length; i++) {
var header = headers[i]
if (header.substr(0, 8) === 'content-' && header !== 'content-location') {
res.removeHeader(header)
}
}
res.removeHeader('Content-Encoding')
res.removeHeader('Content-Language')
res.removeHeader('Content-Length')
res.removeHeader('Content-Range')
res.removeHeader('Content-Type')
}
/**
@@ -787,8 +783,6 @@ SendStream.prototype.sendIndex = function sendIndex (path) {
*/
SendStream.prototype.stream = function stream (path, options) {
// TODO: this is all lame, refactor meeee
var finished = false
var self = this
var res = this.res
@@ -797,20 +791,18 @@ SendStream.prototype.stream = function stream (path, options) {
this.emit('stream', stream)
stream.pipe(res)
// response finished, done with the fd
onFinished(res, function onfinished () {
finished = true
destroy(stream)
})
// cleanup
function cleanup () {
destroy(stream, true)
}
// error handling code-smell
// response finished, cleanup
onFinished(res, cleanup)
// error handling
stream.on('error', function onerror (err) {
// request already finished
if (finished) return
// clean up stream
finished = true
destroy(stream)
// clean up stream early
cleanup()
// error
self.onStatError(err)
@@ -974,6 +966,24 @@ function createHtmlDocument (title, body) {
'</html>\n'
}
/**
* Create a HttpError object from simple arguments.
*
* @param {number} status
* @param {Error|object} err
* @private
*/
function createHttpError (status, err) {
if (!err) {
return createError(status)
}
return err instanceof Error
? createError(status, err, { expose: false })
: createError(status, err)
}
/**
* decodeURIComponent.
*