outgoingMessage.addTrailers(headers)
headers
<Object>
添加 HTTP 尾标(标头,但在消息末尾)到消息。
只有当消息被分块编码时才会触发尾标。 如果没有,则尾标将被默默丢弃。
HTTP 要求发送 Trailer
标头以触发尾标,其值中带有标头字段列表,例如
message.writeHead(200, { 'Content-Type': 'text/plain',
'Trailer': 'Content-MD5' });
message.write(fileData);
message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
message.end();
尝试设置包含无效字符的标头字段名称或值将导致抛出 TypeError
。
headers
<Object>
Adds HTTP trailers (headers but at the end of the message) to the message.
Trailers are only be emitted if the message is chunked encoded. If not, the trailer will be silently discarded.
HTTP requires the Trailer
header to be sent to emit trailers,
with a list of header fields 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();
Attempting to set a header field name or value that contains invalid characters
will result in a TypeError
being thrown.