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.