| 1893 | } |
| 1894 | |
| 1895 | void normalize_curl_result(CURLcode *result, long http_code, |
| 1896 | char *errorstr, size_t errorlen) |
| 1897 | { |
| 1898 | /* |
| 1899 | * If we see a failing http code with CURLE_OK, we have turned off |
| 1900 | * FAILONERROR (to keep the server's custom error response), and should |
| 1901 | * translate the code into failure here. |
| 1902 | * |
| 1903 | * Likewise, if we see a redirect (30x code), that means we turned off |
| 1904 | * redirect-following, and we should treat the result as an error. |
| 1905 | */ |
| 1906 | if (*result == CURLE_OK && http_code >= 300) { |
| 1907 | *result = CURLE_HTTP_RETURNED_ERROR; |
| 1908 | /* |
| 1909 | * Normally curl will already have put the "reason phrase" |
| 1910 | * from the server into curl_errorstr; unfortunately without |
| 1911 | * FAILONERROR it is lost, so we can give only the numeric |
| 1912 | * status code. |
| 1913 | */ |
| 1914 | xsnprintf(errorstr, errorlen, |
| 1915 | "The requested URL returned error: %ld", |
| 1916 | http_code); |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | static int handle_curl_result(struct slot_results *results) |
| 1921 | { |
no test coverage detected