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
12       fail);
13

DESCRIPTION

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

DEFAULT

31       0, do not fail on error
32

PROTOCOLS

34       HTTP
35

EXAMPLE

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

AVAILABILITY

49       Along with HTTP.
50

RETURN VALUE

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

SEE ALSO

55       CURLOPT_HTTP200ALIASES(3), CURLOPT_KEEP_SENDING_ON_ERROR(3),
56
57
58
59libcurl 7.64.0                  April 17, 2018          CURLOPT_FAILONERROR(3)
Impressum