Skip to content

Get url HEADers.

Usage

HEAD(url = NULL, config = list(), ..., handle = NULL)

Arguments

url

the url of the page to retrieve

config

Additional configuration settings such as http authentication (authenticate()), additional headers (add_headers()), cookies (set_cookies()) etc. See config() for full details and list of helpers.

...

Further named parameters, such as query, path, etc, passed on to modify_url(). Unnamed parameters will be combined with config().

handle

The handle to use with this request. If not supplied, will be retrieved and reused from the handle_pool() based on the scheme, hostname and port of the url. By default httr requests to the same scheme/host/port combo. This substantially reduces connection time, and ensures that cookies are maintained over multiple requests to the same host. See handle_pool() for more details.

Value

A response() object.

RFC2616

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.

See also

Other http methods: BROWSE(), DELETE(), GET(), PATCH(), POST(), PUT(), VERB()

Examples

HEAD("http://google.com")
#> Response [http://www.google.com/]
#>   Date: 2023-08-15 18:20
#>   Status: 200
#>   Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
headers(HEAD("http://google.com"))
#> $`content-type`
#> [1] "text/html; charset=ISO-8859-1"
#> 
#> $`content-security-policy-report-only`
#> [1] "object-src 'none';base-uri 'self';script-src 'nonce-s0u_uOyAhx6nsnKQJuBiXA' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp"
#> 
#> $date
#> [1] "Tue, 15 Aug 2023 18:20:26 GMT"
#> 
#> $server
#> [1] "gws"
#> 
#> $`x-xss-protection`
#> [1] "0"
#> 
#> $`x-frame-options`
#> [1] "SAMEORIGIN"
#> 
#> $`transfer-encoding`
#> [1] "chunked"
#> 
#> $expires
#> [1] "Tue, 15 Aug 2023 18:20:26 GMT"
#> 
#> $`cache-control`
#> [1] "private"
#> 
#> $`set-cookie`
#> [1] "1P_JAR=2023-08-15-18; expires=Thu, 14-Sep-2023 18:20:26 GMT; path=/; domain=.google.com; Secure"
#> 
#> $`set-cookie`
#> [1] "AEC=Ad49MVGLs_bDW7e770LDWVS4Hqnqp338FhEWzdk5qzHmFE3EojfAnYTyag; expires=Sun, 11-Feb-2024 18:20:26 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax"
#> 
#> attr(,"class")
#> [1] "insensitive" "list"