response.addTrailers(headers)


该方法向响应添加 HTTP 尾部头(即消息末尾的头)。

【This method adds HTTP trailing headers (a header but at the end of the message) to the response.】

只有在响应使用分块编码时才会发送尾部;如果没有使用(例如请求是 HTTP/1.0),它们将被静默丢弃。

【Trailers will only be emitted if chunked encoding is used for the response; if it is not (e.g. if the request was HTTP/1.0), they will be silently discarded.】

HTTP 要求发送 Trailer 头以便发送尾部信息,其值中应包含头字段的列表。例如:

【HTTP requires the Trailer header to be sent in order to emit trailers, with a list of the header fields in its value. E.g.,】

response.writeHead(200, { 'Content-Type': 'text/plain',
                          'Trailer': 'Content-MD5' });
response.write(fileData);
response.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
response.end(); 

尝试设置包含无效字符的头字段名称或值将导致抛出 TypeError

【Attempting to set a header field name or value that contains invalid characters will result in a TypeError being thrown.】