开发者

Send no content, HTTP header

开发者 https://www.devze.com 2023-01-22 01:56 出处:网络
Is there a HTTP header that makes sure that no content will be displayed? Even if there is some content in the body?

Is there a HTTP header that makes sure that no content will be displayed?

Even if there is some content in the body?

edit:

I take the answers as a "no", and accept the fact that header开发者_Go百科s have no control over the content.


Send the status code 204 No Content.


Is there a HTTP header that makes sure that no content will be displayed?

The best way to make sure no content is displayed is not sending any content - you can never trust the client 100% to do what you want. That said, there is a status code that specifies exactly what you want:

10.2.5 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

0

精彩评论

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