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