1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_NOBODY
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HTTPGET (3)
9  - CURLOPT_MIMEPOST (3)
10  - CURLOPT_POSTFIELDS (3)
11  - CURLOPT_REQUEST_TARGET (3)
12  - CURLOPT_UPLOAD (3)
13---
14
15# NAME
16
17CURLOPT_NOBODY - do the download request without getting the body
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt);
25~~~
26
27# DESCRIPTION
28
29A long parameter set to 1 tells libcurl to not include the body-part in the
30output when doing what would otherwise be a download. For HTTP(S), this makes
31libcurl do a HEAD request. For most other protocols it means just not asking
32to transfer the body data.
33
34For HTTP operations when CURLOPT_NOBODY(3) has been set, disabling this
35option (with 0) makes it a GET again - only if the method is still set to be
36HEAD. The proper way to get back to a GET request is to set
37CURLOPT_HTTPGET(3) and for other methods, use the POST or UPLOAD
38options.
39
40Enabling CURLOPT_NOBODY(3) means asking for a download without a body.
41
42If you do a transfer with HTTP that involves a method other than HEAD, you get
43a body (unless the resource and server sends a zero byte body for the specific
44URL you request).
45
46# DEFAULT
47
480, the body is transferred
49
50# PROTOCOLS
51
52Most
53
54# EXAMPLE
55
56~~~c
57int main(void)
58{
59  CURL *curl = curl_easy_init();
60  if(curl) {
61    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
62
63    /* get us the resource without a body - use HEAD! */
64    curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
65
66    /* Perform the request */
67    curl_easy_perform(curl);
68  }
69}
70~~~
71
72# AVAILABILITY
73
74Always
75
76# RETURN VALUE
77
78Returns CURLE_OK
79