Express 相关
Published by powerfulyang on Apr 8, 2022
Relate to https://stackoverflow.com/a/7086621
Comprehensive list of Node.js/Express response methods and when they must be called:
Response must be in Head and remains in Head:
res.writeContinue()
res.statusCode = 404
res.setHeader(name, value)
res.getHeader(name)
res.removeHeader(name)
res.header(key[, val])
(Express only)res.charset = 'utf-8'
(Express only; only affects Express-specific methods)res.contentType(type)
(Express only)
Response must be in Head and becomes Body:
Response can be in either Head/Body and remains in Body:
Response can be in either Head/Body and becomes Finished:
Response can be in either Head/Body and remains in its current state:
Response must be in Head and becomes Finished:
return next([err])
(Connect/Express only)- Any exceptions within middleware
function(req, res, next)
(Connect/Express only) res.send(body|status[, headers|status[, status]])
(Express only)res.attachment(filename)
(Express only)res.sendfile(path[, options[, callback]])
(Express only)res.json(obj[, headers|status[, status]])
(Express only)res.redirect(url[, status])
(Express only)res.cookie(name, val[, options])
(Express only)res.clearCookie(name[, options])
(Express only)res.render(view[, options[, fn]])
(Express only)res.partial(view[, options])
(Express only)
目录: