This commit is contained in:
2026-07-26 21:23:30 +00:00
parent 6fa0e1b9a6
commit 7c262aeb8b
60 changed files with 2359 additions and 582 deletions
+17 -17
View File
@@ -11,13 +11,13 @@
* @private
*/
var createError = require('http-errors')
var getBody = require('raw-body')
var iconv = require('iconv-lite')
var onFinished = require('on-finished')
var zlib = require('node:zlib')
var hasBody = require('type-is').hasBody
var { getCharset } = require('./utils')
const createError = require('http-errors')
const getBody = require('raw-body')
const iconv = require('iconv-lite')
const onFinished = require('on-finished')
const zlib = require('node:zlib')
const hasBody = require('type-is').hasBody
const { getCharset } = require('./utils')
/**
* Module exports.
@@ -63,7 +63,7 @@ function read (req, res, next, parse, debug, options) {
return
}
var encoding = null
let encoding = null
if (options?.skipCharset !== true) {
encoding = getCharset(req) || options.defaultCharset
@@ -78,12 +78,12 @@ function read (req, res, next, parse, debug, options) {
}
}
var length
var opts = options
var stream
let length
const opts = options
let stream
// read options
var verify = opts.verify
const verify = opts.verify
try {
// get the content stream
@@ -112,7 +112,7 @@ function read (req, res, next, parse, debug, options) {
debug('read body')
getBody(stream, opts, function (error, body) {
if (error) {
var _error
let _error
if (error.type === 'encoding.unsupported') {
// echo back charset
@@ -153,7 +153,7 @@ function read (req, res, next, parse, debug, options) {
}
// parse
var str = body
let str = body
try {
debug('parse body')
str = typeof body !== 'string' && encoding !== null
@@ -182,8 +182,8 @@ function read (req, res, next, parse, debug, options) {
* @private
*/
function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
const length = req.headers['content-length']
debug('content-encoding "%s"', encoding)
@@ -199,7 +199,7 @@ function contentstream (req, debug, inflate) {
return req
}
var stream = createDecompressionStream(encoding, debug)
const stream = createDecompressionStream(encoding, debug)
req.pipe(stream)
return stream
}