CURLOPT_NOBODY.md (1885B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_NOBODY 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HTTPGET (3) 9 - CURLOPT_MIMEPOST (3) 10 - CURLOPT_POSTFIELDS (3) 11 - CURLOPT_REQUEST_TARGET (3) 12 - CURLOPT_UPLOAD (3) 13 Protocol: 14 - All 15 Added-in: 7.1 16 --- 17 18 # NAME 19 20 CURLOPT_NOBODY - do the download request without getting the body 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt); 28 ~~~ 29 30 # DESCRIPTION 31 32 A long parameter set to 1 tells libcurl to not include the body-part in the 33 output when doing what would otherwise be a download. For HTTP(S), this makes 34 libcurl do a HEAD request. For most other protocols it means just not asking 35 to transfer the body data. 36 37 For HTTP operations when CURLOPT_NOBODY(3) has been set, disabling this 38 option (with 0) makes it a GET again - only if the method is still set to be 39 HEAD. The proper way to get back to a GET request is to set 40 CURLOPT_HTTPGET(3) and for other methods, use the POST or UPLOAD 41 options. 42 43 Enabling CURLOPT_NOBODY(3) means asking for a download without a body. 44 45 If you do a transfer with HTTP that involves a method other than HEAD, you get 46 a body (unless the resource and server sends a zero byte body for the specific 47 URL you request). 48 49 # DEFAULT 50 51 0, the body is transferred 52 53 # %PROTOCOLS% 54 55 # EXAMPLE 56 57 ~~~c 58 int 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 77 curl_easy_setopt(3) returns a CURLcode indicating success or error. 78 79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 80 libcurl-errors(3).