xref: /aosp_15_r20/external/curl/docs/libcurl/opts/CURLOPT_NOBODY.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: CURLOPT_NOBODY
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_HTTPGET (3)
9*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_MIMEPOST (3)
10*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_POSTFIELDS (3)
11*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_REQUEST_TARGET (3)
12*6236dae4SAndroid Build Coastguard Worker  - CURLOPT_UPLOAD (3)
13*6236dae4SAndroid Build Coastguard WorkerProtocol:
14*6236dae4SAndroid Build Coastguard Worker  - All
15*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.1
16*6236dae4SAndroid Build Coastguard Worker---
17*6236dae4SAndroid Build Coastguard Worker
18*6236dae4SAndroid Build Coastguard Worker# NAME
19*6236dae4SAndroid Build Coastguard Worker
20*6236dae4SAndroid Build Coastguard WorkerCURLOPT_NOBODY - do the download request without getting the body
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard Worker~~~c
25*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h>
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard WorkerCURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt);
28*6236dae4SAndroid Build Coastguard Worker~~~
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard WorkerA long parameter set to 1 tells libcurl to not include the body-part in the
33*6236dae4SAndroid Build Coastguard Workeroutput when doing what would otherwise be a download. For HTTP(S), this makes
34*6236dae4SAndroid Build Coastguard Workerlibcurl do a HEAD request. For most other protocols it means just not asking
35*6236dae4SAndroid Build Coastguard Workerto transfer the body data.
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerFor HTTP operations when CURLOPT_NOBODY(3) has been set, disabling this
38*6236dae4SAndroid Build Coastguard Workeroption (with 0) makes it a GET again - only if the method is still set to be
39*6236dae4SAndroid Build Coastguard WorkerHEAD. The proper way to get back to a GET request is to set
40*6236dae4SAndroid Build Coastguard WorkerCURLOPT_HTTPGET(3) and for other methods, use the POST or UPLOAD
41*6236dae4SAndroid Build Coastguard Workeroptions.
42*6236dae4SAndroid Build Coastguard Worker
43*6236dae4SAndroid Build Coastguard WorkerEnabling CURLOPT_NOBODY(3) means asking for a download without a body.
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard WorkerIf you do a transfer with HTTP that involves a method other than HEAD, you get
46*6236dae4SAndroid Build Coastguard Workera body (unless the resource and server sends a zero byte body for the specific
47*6236dae4SAndroid Build Coastguard WorkerURL you request).
48*6236dae4SAndroid Build Coastguard Worker
49*6236dae4SAndroid Build Coastguard Worker# DEFAULT
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard Worker0, the body is transferred
52*6236dae4SAndroid Build Coastguard Worker
53*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS%
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard Worker# EXAMPLE
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard Worker~~~c
58*6236dae4SAndroid Build Coastguard Workerint main(void)
59*6236dae4SAndroid Build Coastguard Worker{
60*6236dae4SAndroid Build Coastguard Worker  CURL *curl = curl_easy_init();
61*6236dae4SAndroid Build Coastguard Worker  if(curl) {
62*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
63*6236dae4SAndroid Build Coastguard Worker
64*6236dae4SAndroid Build Coastguard Worker    /* get us the resource without a body - use HEAD */
65*6236dae4SAndroid Build Coastguard Worker    curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
66*6236dae4SAndroid Build Coastguard Worker
67*6236dae4SAndroid Build Coastguard Worker    /* Perform the request */
68*6236dae4SAndroid Build Coastguard Worker    curl_easy_perform(curl);
69*6236dae4SAndroid Build Coastguard Worker  }
70*6236dae4SAndroid Build Coastguard Worker}
71*6236dae4SAndroid Build Coastguard Worker~~~
72*6236dae4SAndroid Build Coastguard Worker
73*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY%
74*6236dae4SAndroid Build Coastguard Worker
75*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE
76*6236dae4SAndroid Build Coastguard Worker
77*6236dae4SAndroid Build Coastguard WorkerReturns CURLE_OK
78