1CURLOPT_FAILONERROR(3)     curl_easy_setopt options     CURLOPT_FAILONERROR(3)
2
3
4

NAME

6       CURLOPT_FAILONERROR - request failure on HTTP response >= 400
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FAILONERROR, long fail);
12

DESCRIPTION

14       A  long parameter set to 1 tells the library to fail the request if the
15       HTTP code returned is equal to or larger than 400. The  default  action
16       would be to return the page normally, ignoring that code.
17
18       This method is not fail-safe and there are occasions where non-success‐
19       ful response codes will slip through, especially when authentication is
20       involved (response codes 401 and 407).
21
22       You might get some amounts of headers transferred before this situation
23       is detected, like when a "100-continue" is received as a response to  a
24       POST/PUT and a 401 or 407 is received immediately afterwards.
25
26       When  this  option  is used and an error is detected, it will cause the
27       connection to get closed and CURLE_HTTP_RETURNED_ERROR is returned.
28

DEFAULT

30       0, do not fail on error
31

PROTOCOLS

33       HTTP
34

EXAMPLE

36       CURL *curl = curl_easy_init();
37       if(curl) {
38         CURLcode ret;
39         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
40         curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
41         ret = curl_easy_perform(curl);
42         if(ret == CURLE_HTTP_RETURNED_ERROR) {
43           /* an HTTP response error problem */
44         }
45       }
46

AVAILABILITY

48       Along with HTTP.
49

RETURN VALUE

51       Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not.
52

SEE ALSO

54       CURLOPT_HTTP200ALIASES(3), CURLOPT_KEEP_SENDING_ON_ERROR(3),
55
56
57
58libcurl 7.85.0                   May 17, 2022           CURLOPT_FAILONERROR(3)
Impressum