1CURLOPT_FAILONERROR(3) curl_easy_setopt options CURLOPT_FAILONERROR(3)
2
3
4
6 CURLOPT_FAILONERROR - request failure on HTTP response >= 400
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FAILONERROR, long fail);
12
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
30 0, do not fail on error
31
33 HTTP
34
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
48 Along with HTTP.
49
51 Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not.
52
54 CURLOPT_HTTP200ALIASES(3), CURLOPT_KEEP_SENDING_ON_ERROR(3),
55
56
57
58libcurl 7.82.0 November 26, 2021 CURLOPT_FAILONERROR(3)