From 2d585f2b0b6a5dc587f3e3ebb9bde6ca561717ed Mon Sep 17 00:00:00 2001 From: Ludvig Rappe Date: Fri, 7 Feb 2020 13:24:53 +0000 Subject: [PATCH] gstcurlhttpsink: Update HTTP header for curl 7.66 Change how content-length is set for HTTP POST headers, letting curl set the header (given the content-length) instead of manually writing it. This enables curl to know the content-length of the data. In curl 7.66, if curl does not know the content-length (e.g. when manually writing the header) curl will use Transfer-Encoding: chunked, which might not be desired. --- ext/curl/gstcurlhttpsink.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/curl/gstcurlhttpsink.c b/ext/curl/gstcurlhttpsink.c index e9e348ea92..4c32dcca21 100644 --- a/ext/curl/gstcurlhttpsink.c +++ b/ext/curl/gstcurlhttpsink.c @@ -335,10 +335,14 @@ gst_curl_http_sink_set_header_unlocked (GstCurlBaseSink * bcsink) if (sink->use_content_length) { /* if content length is used we assume that every buffer is one * entire file, which is the case when uploading several jpegs */ - tmp = - g_strdup_printf ("Content-Length: %d", (int) bcsink->transfer_buf->len); - sink->header_list = curl_slist_append (sink->header_list, tmp); - g_free (tmp); + res = + curl_easy_setopt (bcsink->curl, CURLOPT_POSTFIELDSIZE, + (long) bcsink->transfer_buf->len); + if (res != CURLE_OK) { + bcsink->error = g_strdup_printf ("failed to set HTTP content-length: %s", + curl_easy_strerror (res)); + return FALSE; + } } else { /* when sending a POST request to a HTTP 1.1 server, you can send data * without knowing the size before starting the POST if you use chunked