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