From dd1c85dc1e6ce27f6cd0240fe6510c8b729f10de Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 30 Oct 2023 11:59:29 +0100 Subject: [PATCH] Add new parameter curl_cookiefile for curl_easy_setopt This allows OCR for URLs which require a session cookie. Signed-off-by: Stefan Weil --- src/api/baseapi.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index 0823fd3a..bbc77f48 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -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");