Answer
HEAD Method
The HEAD method asks for a response identical to a GET request, but without the response body.
Use Cases
- ✓Check if a resource exists without downloading it
- ✓Get metadata (Content-Type, Content-Length, Last-Modified) without the actual content
- ✓Performance optimization — verify headers before making full GET
- ✓Link validation — check URLs are alive without fetching full pages
Example
CODE
HEAD /api/files/large-document.pdf HTTP/1.1
Host: api.example.com
Response:
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 2097152
Last-Modified: Thu, 19 Jun 2026 10:00:00 GMT
No body is returned — just the headers.
In Rest Assured
Java
Response response = given()
.when()
.head("https://api.example.com/users/1");
assertEquals(response.getStatusCode(), 200);
// response.getBody() will be empty
HEAD vs GET
| Feature | HEAD | GET |
|---|---|---|
| Returns headers | Yes | Yes |
| Returns body | No | Yes |
| Use for metadata | Yes | Possible but inefficient |
