response.getHeader(name)
添加于:v0.4.0
参数
读出已排队但未发送到客户端的标头。名称不区分大小写。返回值的类型取决于提供给
的参数。response.setHeader()
response.setHeader('Content-Type', 'text/html');
response.setHeader('Content-Length', Buffer.byteLength(body));
response.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);
const contentType = response.getHeader('content-type');
// contentType is 'text/html'
const contentLength = response.getHeader('Content-Length');
// contentLength is of type number
const setCookie = response.getHeader('set-cookie');
// setCookie is of type string[]
相关用法
- Node.js http2.Http2ServerResponse response.getHeader(name)用法及代码示例
- Node.js http.ServerResponse response.getHeaderNames()用法及代码示例
- Node.js http.ServerResponse response.getHeaders()用法及代码示例
- Node.js response.getHeaders()用法及代码示例
- Node.js http2.Http2ServerResponse response.getHeaders()用法及代码示例
- Node.js response.getHeaderNames()用法及代码示例
- Node.js http2.Http2ServerResponse response.getHeaderNames()用法及代码示例
- Node.js http.ServerResponse response.statusCode用法及代码示例
- Node.js response.writeContinue()用法及代码示例
- Node.js http2.Http2ServerResponse response.removeHeader(name)用法及代码示例
- Node.js response.removeHeader()用法及代码示例
- Node.js http2.Http2ServerResponse response.hasHeader(name)用法及代码示例
- Node.js http.ServerResponse response.removeHeader(name)用法及代码示例
- Node.js http.ServerResponse response.hasHeader(name)用法及代码示例
- Node.js response.setHeader()用法及代码示例
- Node.js http2.Http2ServerResponse response.setHeader(name, value)用法及代码示例
- Node.js response.hasHeader()用法及代码示例
- Node.js http.ServerResponse response.socket用法及代码示例
- Node.js response.writeHead()用法及代码示例
- Node.js http2.Http2ServerResponse response.writeHead(statusCode[, statusMessage][, headers])用法及代码示例
- Node.js response.addTrailers()用法及代码示例
- Node.js http.ServerResponse response.statusMessage用法及代码示例
- Node.js response.write()用法及代码示例
- Node.js http.ServerResponse response.setHeader(name, value)用法及代码示例
- Node.js http.ServerResponse response.addTrailers(headers)用法及代码示例
注:本文由纯净天空筛选整理自nodejs.org大神的英文原创作品 response.getHeader(name)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。