MDN Web Docs

Syntax

http

HEAD <request-target>["?"<query>] HTTP/1.1
<request-target>

Identifies the target resource of the request when combined with the information provided in the Host header. This is an absolute path (e.g., /path/to/file.html) in requests to an origin server, and an absolute URL in requests to proxies (e.g., http://www.example.com/path/to/file.html).

<query> Optional

An optional query component preceded by a question-mark ?. Often used to carry identifying information in the form of key=value pairs.

Examples

Successfully retrieving resource metadata

The following curl command creates a HEAD request for example.com:

bash

curl --head example.com

This is the equivalent to a GET request, except the server shouldn't include a message body in the response. It creates an HTTP request that looks like this:

http

HEAD / HTTP/1.1
Host: example.com
User-Agent: curl/8.6.0
Accept: */*

The server sends back a 200 OK response comprised only of headers. The response is effectively metadata that describes the resource instead of the resource itself (some caching headers are omitted in this example for brevity):

http

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date: Wed, 04 Sep 2024 10:33:11 GMT
Content-Length: 1234567

Specifications

Specification
HTTP Semantics
# HEAD

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗