diff mbox series

[18/29] channel_curl: add the possibility to request a range

Message ID 20211011112156.44192-19-sbabic@denx.de
State Changes Requested
Headers show
Series DELTA Update | expand

Commit Message

Stefano Babic Oct. 11, 2021, 11:21 a.m. UTC
This allow to set a range request for a file to be downloaded.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/channel_curl.c | 9 +++++++++
 include/channel_curl.h | 1 +
 2 files changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index abe252c..bed631b 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -757,6 +757,15 @@  channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da
 		}
 	}
 
+	if (channel_data->range) {
+		if (curl_easy_setopt(channel_curl->handle, CURLOPT_RANGE,
+				     channel_data->range) != CURLE_OK) {
+			ERROR("Bytes Range could not be set.");
+			result = CHANNEL_EINIT;
+			goto cleanup;
+		}
+	}
+
 cleanup:
 	return result;
 }
diff --git a/include/channel_curl.h b/include/channel_curl.h
index 7d1e892..4409dca 100644
--- a/include/channel_curl.h
+++ b/include/channel_curl.h
@@ -79,5 +79,6 @@  typedef struct {
 	struct dict *headers_to_send;
 	struct dict *received_headers;
 	unsigned int max_download_speed;
+	char *range; /* Range request for get_file in any */
 	void *user;
 } channel_data_t;