async function read(req, res, next, parse, options) {
  req._parsedBody = true;
  const encoding = options.encoding;
  const verify = options.verify;
  let raw;
  try {
    raw = await decodeContent(req, options.inflate);
  } catch (err) {
    next(err);
    return;
  }
  if (verify) {
    try {
      verify(req, res, raw, encoding);
    } catch (err) {
      next(createError(403, err, {
        body: raw,
        type: err.type ?? "entity.verify.failed",
      }));
      return;
    }
  }
  let str;
  try {
    str = typeof raw !== "string" && encoding !== null
      ? new TextDecoder(encoding).decode(raw)
      : raw;
    req.parsedBody = parse(str);
  } catch (err) {
    next(createError(400, err, {
      body: str ?? raw,
      type: err.type ?? "entity.parse.failed",
    }));
    return;
  }
  next();
}
/**
 * Read a request into a buffer and parse.
 *
 * @param {Request} req
 * @param {Response} res
 * @param {Function} next
 * @param {Function} parse
 * @param {object} options
 * @private
 */
Read a request into a buffer and parse.
Read a request into a buffer and parse .
async function read(req, res, next, parse, options) {
  req._parsedBody = true;
  const encoding = options.encoding;
  const verify = options.verify;
  let raw;
  try {
    raw = await decodeContent(req, options.inflate);
  } catch (err) {
    next(err);
    return;
  }
  if (verify) {
    try {
      verify(req, res, raw, encoding);
    } catch (err) {
      next(createError(403, err, {
        body: raw,
        type: err.type ?? "entity.verify.failed",
      }));
      return;
    }
  }
  let str;
  try {
    str = typeof raw !== "string" && encoding !== null
      ? new TextDecoder(encoding).decode(raw)
      : raw;
    req.parsedBody = parse(str);
  } catch (err) {
    next(createError(400, err, {
      body: str ?? raw,
      type: err.type ?? "entity.parse.failed",
    }));
    return;
  }
  next();
}
async function read ( req , res , next , parse , options ) { req . _parsedBody = true ; const encoding = options . encoding ; const verify = options . verify ; let raw ; try { raw = await decodeContent ( req , options . inflate ) ; } catch ( err ) { next ( err ) ; return ; } if ( verify ) { try { verify ( req , res , raw , encoding ) ; } catch ( err ) { next ( createError ( 403 , err , { body : raw , type : err . type ?? "entity.verify.failed" , } ) ) ; return ; } } let str ; try { str = typeof raw !== "string" && encoding !== null ? new TextDecoder ( encoding ) . decode ( raw ) : raw ; req . parsedBody = parse ( str ) ; } catch ( err ) { next ( createError ( 400 , err , { body : str ?? raw , type : err . type ?? "entity.parse.failed" , } ) ) ; return ; } next ( ) ; }
Read a request into a buffer and parse.
Read a request into a buffer and parse .