outgoingMessage.addTrailers(headers)


添加 HTTP 尾标(标头,但在消息末尾)到消息。

【Adds HTTP trailers (headers but at the end of the message) to the message.】

只有在消息使用分块编码时,才会发送尾部信息。如果不是,尾部信息将被静默丢弃。

【Trailers will only be emitted if the message is chunked encoded. If not, the trailers will be silently discarded.】

HTTP 要求发送 Trailer 头以发出尾部信息,其值中包含一个头字段名称的列表,例如。

【HTTP requires the Trailer header to be sent to emit trailers, with a list of header field names in its value, e.g.】

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

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

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