From 6789d8239e80a703ef950d6a017ebe110e77f529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= Date: Sun, 14 Feb 2021 13:16:48 +0100 Subject: [PATCH] escl: Follow the 302 redirects Recent ipp-usb redirects from http://127.0.0.1 to http://localhost (cherry picked from commit 570984a9a2172ad98ac357e99c3859c4d27c00ba) --- backend/escl/escl_capabilities.c | 2 ++ backend/escl/escl_newjob.c | 2 ++ backend/escl/escl_reset.c | 2 ++ backend/escl/escl_scan.c | 2 ++ backend/escl/escl_status.c | 2 ++ 5 files changed, 10 insertions(+) diff --git a/backend/escl/escl_capabilities.c b/backend/escl/escl_capabilities.c index 3e167116d..7422896a2 100644 --- a/backend/escl/escl_capabilities.c +++ b/backend/escl/escl_capabilities.c @@ -554,6 +554,8 @@ escl_capabilities(ESCL_Device *device, char *blacklist, SANE_Status *status) curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var); curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, header_callback); curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)header); + curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L); CURLcode res = curl_easy_perform(curl_handle); if (res == CURLE_OK) DBG( 1, "Create NewJob : the scanner header responded : [%s]\n", header->memory); diff --git a/backend/escl/escl_newjob.c b/backend/escl/escl_newjob.c index ab81a9ad8..98a953fdf 100644 --- a/backend/escl/escl_newjob.c +++ b/backend/escl/escl_newjob.c @@ -277,6 +277,8 @@ wake_up_device: curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, upload->size); curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, download_callback); curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)download); + curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L); CURLcode res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { DBG( 1, "Create NewJob : the scanner responded incorrectly: %s\n", curl_easy_strerror(res)); diff --git a/backend/escl/escl_reset.c b/backend/escl/escl_reset.c index e6829aa56..95e3f2d31 100644 --- a/backend/escl/escl_reset.c +++ b/backend/escl/escl_reset.c @@ -62,6 +62,8 @@ CURL_CALL: scan_jobs, scanJob, result, scanner_start); escl_curl_url(curl_handle, device, scan_cmd); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback); + curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L); if (curl_easy_perform(curl_handle) == CURLE_OK) { curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &answer); i++; diff --git a/backend/escl/escl_scan.c b/backend/escl/escl_scan.c index fe740976f..3350c8371 100644 --- a/backend/escl/escl_scan.c +++ b/backend/escl/escl_scan.c @@ -74,6 +74,8 @@ escl_scan(capabilities_t *scanner, const ESCL_Device *device, char *scanJob, cha scan_jobs, scanJob, result, scanner_start); escl_curl_url(curl_handle, device, scan_cmd); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback); + curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L); if (scanner->tmp) fclose(scanner->tmp); scanner->tmp = tmpfile(); diff --git a/backend/escl/escl_status.c b/backend/escl/escl_status.c index a68f6eae0..1f848a2c8 100644 --- a/backend/escl/escl_status.c +++ b/backend/escl/escl_status.c @@ -220,6 +220,8 @@ reload: escl_curl_url(curl_handle, device, scanner_status); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_s); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var); + curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L); CURLcode res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { DBG( 1, "The scanner didn't respond: %s\n", curl_easy_strerror(res));