xref: /curl/docs/libcurl/opts/CURLOPT_HTTPGET.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_HTTPGET
5Section: 3
6Source: libcurl
7Protocol:
8  - HTTP
9See-also:
10  - CURLOPT_NOBODY (3)
11  - CURLOPT_POST (3)
12  - CURLOPT_UPLOAD (3)
13  - curl_easy_reset (3)
14Added-in: 7.8.1
15---
16
17# NAME
18
19CURLOPT_HTTPGET - ask for an HTTP GET request
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPGET, long useget);
27~~~
28
29# DESCRIPTION
30
31Pass a long. If *useget* is 1, this forces the HTTP request to get back to
32using GET. Usable if a POST, HEAD, PUT, etc has been used previously using the
33same curl *handle*.
34
35When setting CURLOPT_HTTPGET(3) to 1, libcurl automatically sets
36CURLOPT_NOBODY(3) to 0 and CURLOPT_UPLOAD(3) to 0.
37
38Setting this option to zero has no effect. Applications need to explicitly
39select which HTTP request method to use, they cannot deselect a method. To
40reset a handle to default method, consider curl_easy_reset(3).
41
42# DEFAULT
43
440
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int 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
70Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
71