Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Request methods
  5. HEAD

HEAD request method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheHEAD HTTP method requests the metadata of a resource in the form ofheaders that the server would have sent if theGET method was used instead.This method can be used in cases where a URL might produce a large download, for example, aHEAD request can read theContent-Length header to check the file size before downloading the file with aGET.

If the response to aHEAD request shows that a cached URL response is now outdated, the cached copy is invalidated even if noGET request was made.

Warning:If a response to aHEAD request has a body, the response body must be ignored.Anyrepresentation headers that describe the erroneous body are assumed to describe the response body that aGET request would have received.

Request has bodyNo
Successful response has bodyNo
SafeYes
IdempotentYes
CacheableYes
Allowed inHTML formsNo

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 theHost 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 ofkey=value pairs.

Examples

Successfully retrieving resource metadata

The followingcurl command creates aHEAD request forexample.com:

bash
curl --head example.com

This is the equivalent to aGET 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.1Host: example.comUser-Agent: curl/8.6.0Accept: */*

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

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

Specifications

Specification
HTTP Semantics
# HEAD

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp