Skip to content

Commit

Permalink
Fail on curl download errors
Browse files Browse the repository at this point in the history
Fail with an error message instead of trying to handle the text
from an HTML error page as an image and fail later for HTTP codes
equal or larger than 400.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Oct 31, 2023
1 parent dd1c85d commit 36f3efd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,10 @@ bool TessBaseAPI::ProcessPagesInternal(const char *filename, const char *retry_c
if (curlcode != CURLE_OK) {
return error("curl_easy_setopt");
}
curlcode = curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
if (curlcode != CURLE_OK) {
return error("curl_easy_setopt");
}
// Follow HTTP, HTTPS, FTP and FTPS redirects.
curlcode = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
if (curlcode != CURLE_OK) {
Expand Down

0 comments on commit 36f3efd

Please sign in to comment.