curlhttpsrc: Various fixes
Copied from https://gitlab.freedesktop.org//gstreamer/gst-plugins-bad/-/merge_requests/2166
- Fix request restart logic
Can get into an infinite loop if request is removed from loop (by seek for instance). It thinks the transfer is in progress, but can't make any progress.
gst_curl_http_src_unlock() called, state=OK
Connection closed
gst_curl_http_src_create() continues, state=UNLOCKED
gst_curl_http_src_do_seek() for 283665
gst_curl_http_src_create(), transfer_begun=TRUE, buffer_len=0, state=REMOVED, status=NOT_CONNECTED
... last two items keep repeating ...
- Reset request status on uri change
Existing code doesn't know that the uri has been changed and won't start a new request on pipeline start.
- Fix content size reported
Current code incorrectly returns the Content-Length on a range request which is the total transferred, not the total size of the resource. Use the Content-Range header if available to report the correct length.