Add new parameter curl_cookiefile for curl_easy_setopt

This allows OCR for URLs which require a session cookie.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2023-10-30 11:59:29 +01:00
parent bb2af57054
commit dd1c85dc1e

View File

@ -101,6 +101,7 @@ static BOOL_VAR(stream_filelist, false, "Stream a filelist from stdin");
static STRING_VAR(document_title, "", "Title of output document (used for hOCR and PDF output)");
#ifdef HAVE_LIBCURL
static INT_VAR(curl_timeout, 0, "Timeout for curl in seconds");
static STRING_VAR(curl_cookiefile, "", "File with cookie data for curl");
#endif
/** Minimum sensible image size to be worth running Tesseract. */
@ -1164,6 +1165,13 @@ bool TessBaseAPI::ProcessPagesInternal(const char *filename, const char *retry_c
return error("curl_easy_setopt");
}
}
std::string cookiefile = curl_cookiefile;
if (!cookiefile.empty()) {
curlcode = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, cookiefile.c_str());
if (curlcode != CURLE_OK) {
return error("curl_easy_setopt");
}
}
curlcode = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
if (curlcode != CURLE_OK) {
return error("curl_easy_setopt");