CURLOPT_HTTPGET.md (1502B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_HTTPGET 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - HTTP 9 See-also: 10 - CURLOPT_NOBODY (3) 11 - CURLOPT_POST (3) 12 - CURLOPT_UPLOAD (3) 13 - curl_easy_reset (3) 14 Added-in: 7.8.1 15 --- 16 17 # NAME 18 19 CURLOPT_HTTPGET - ask for an HTTP GET request 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPGET, long useget); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a long. If *useget* is 1, this forces the HTTP request to get back to 32 using GET. Usable if a POST, HEAD, PUT, etc has been used previously using the 33 same curl *handle*. 34 35 When setting CURLOPT_HTTPGET(3) to 1, libcurl automatically sets 36 CURLOPT_NOBODY(3) to 0 and CURLOPT_UPLOAD(3) to 0. 37 38 Setting this option to zero has no effect. Applications need to explicitly 39 select which HTTP request method to use, they cannot deselect a method. To 40 reset a handle to default method, consider curl_easy_reset(3). 41 42 # DEFAULT 43 44 0 45 46 # %PROTOCOLS% 47 48 # EXAMPLE 49 50 ~~~c 51 int main(void) 52 { 53 CURL *curl = curl_easy_init(); 54 if(curl) { 55 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 56 57 /* use a GET to fetch this */ 58 curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); 59 60 /* Perform the request */ 61 curl_easy_perform(curl); 62 } 63 } 64 ~~~ 65 66 # %AVAILABILITY% 67 68 # RETURN VALUE 69 70 curl_easy_setopt(3) returns a CURLcode indicating success or error. 71 72 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 73 libcurl-errors(3).