Generally you should only need to use this function to set CURL options
directly if there isn't already a helpful wrapper function, like
set_cookies()
, add_headers()
or
authenticate()
. To use this function effectively requires
some knowledge of CURL, and CURL options. Use httr_options()
to
see a complete list of available options. To see the libcurl documentation
for a given option, use curl_docs()
.
See also
set_config()
to set global config defaults, and
with_config()
to temporarily run code with set options.
All known available options are listed in httr_options()
Other config:
add_headers()
,
authenticate()
,
set_cookies()
,
timeout()
,
use_proxy()
,
user_agent()
,
verbose()
Other ways to set configuration:
set_config()
,
with_config()
Examples
# There are a number of ways to modify the configuration of a request
# * you can add directly to a request
HEAD("https://www.google.com", verbose())
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
# * you can wrap with with_config()
with_config(verbose(), HEAD("https://www.google.com"))
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
# * you can set global with set_config()
old <- set_config(verbose())
HEAD("https://www.google.com")
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
# and re-establish the previous settings with
set_config(old, override = TRUE)
HEAD("https://www.google.com")
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
# or
reset_config()
HEAD("https://www.google.com")
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>
# If available, you should use a friendly httr wrapper over RCurl
# options. But you can pass Curl options (as listed in httr_options())
# in config
HEAD("https://www.google.com/", config(verbose = TRUE))
#> Response [https://www.google.com/]
#> Date: 2023-08-15 18:20
#> Status: 200
#> Content-Type: text/html; charset=ISO-8859-1
#> <EMPTY BODY>