HEAD
This method returns only the header part of a GET request. It can be used for obtaining metadata about the selected representation, without transferring the representation data.
Writing requests (clients)
HEAD may be used in any case where the client needs metadata about the resource, available from headers, but not the payload itself. The response will always end at the end of the header section, even in the presence of headers to the contrary (e.g. Content-Length
The server is allowed to omit several header fields related to payload, however (Content-Length, Content-Range, Trailer, Transfer-Encoding). The same GET request might add these fields.
Reading requests (servers)
Servers may implement HEAD by processing the request as a GET request, and discarding the response payload, or terminating the request after the headers are fully written out (this works because GET requests are not supposed to impact the server state).
Overview table
- Name
- HEAD
- Description
- Returns GET request without payload
- Conditional fail
- 304 Not Modified
- Request payload
- Undefined
- Response payload
- Prohibited
- Cachable
- Cachable
- Specification
- RFC 5789: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content. 4.3.2. HEAD
Implementations
Node.js (http/https/http2)
Node.js will never allow data to be written to a HEAD response, however it is the job of the implementation to ensure the response is handled the same as an equivalent GET request.