开发者

Is it OK to send an HTTP response with file attachment without specifying the Content-Length?

开发者 https://www.devze.com 2023-01-16 12:23 出处:网络
Meaning wi开发者_运维问答ll it work fine? I have a situation where I am attaching files via HTTP attachment by attaching the URI of the file and it is on a different server so I don\'t have access to

Meaning wi开发者_运维问答ll it work fine? I have a situation where I am attaching files via HTTP attachment by attaching the URI of the file and it is on a different server so I don't have access to the length of the file.


It will work fine. The client will just read to EOF. The client only won't be able to calculate/estimate the progress of download.


It may work fine but the HTTP spec states that applications SHOULD send the length if it's possible to determine:

Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.

Any Content-Length greater than or equal to zero is a valid value. Section 4.4 describes how to determine the length of a message-body if a Content-Length is not given.

Note that the meaning of this field is significantly different from the corresponding definition in MIME, where it is an optional field used within the "message/external-body" content-type. In HTTP, it SHOULD be sent whenever the message's length can be determined prior to being transferred, unless this is prohibited by the rules in section 4.4.

0

精彩评论

暂无评论...
验证码 换一张
取 消