简体   繁体   中英

Query regarding HTTP headers and HTTP response status

I am trying to build a REST service and I have a few questions.

  1. When I send Location header is body required?
  2. If-modified-since : Can this header value be null or not set to indicate whatever latest version in PUT and DELETE calls?
  1. No, the Location header does not require body content. In fact, if the status code of the response is 302 Found or a similar redirect, body content would make no sense.
  2. The header If-modified-since is part of the HTTP concept 'Conditional GET'. If it is not set and if not other header that is part of this concept ( If-Match , If-None-Match , If-Unmodified-Since ) is set, the server is supposed to return a representation of the current resource.

In fact, Conditional GET is not a concept about versions but about caching. If the client already knows a representation of the resource that is still up-to-date, it would be redundand for the server to return the same representation again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM