diff options
author | Max Kellermann <max@musicpd.org> | 2017-10-24 21:41:17 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-10-24 21:41:17 +0200 |
commit | ff162b5a03123d5f8e309c8f37fc4ba583d0d63b (patch) | |
tree | b57c2208010e0921f149f9260dc73f4505237736 /src/input/plugins/CurlInputPlugin.cxx | |
parent | d8e4705dd443a7622049ca6733a35df3c0f59ebe (diff) |
input/curl: move code to StartRequest()
Diffstat (limited to 'src/input/plugins/CurlInputPlugin.cxx')
-rw-r--r-- | src/input/plugins/CurlInputPlugin.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index 141956c03..679cc7d72 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -85,9 +85,20 @@ struct CurlInputStream final : public AsyncInputStream, CurlResponseHandler { static InputStream *Open(const char *url, Mutex &mutex, Cond &cond); + /** + * Create and initialize a new #CurlRequest instance. After + * this, you may add more request headers and set options. To + * actually start the request, call StartRequest(). + */ void InitEasy(); /** + * Start the request after having called InitEasy(). After + * this, you must not set any CURL options. + */ + void StartRequest(); + + /** * Frees the current "libcurl easy" handle, and everything * associated with it. * @@ -371,6 +382,11 @@ CurlInputStream::InitEasy() request_headers.Clear(); request_headers.Append("Icy-Metadata: 1"); +} + +void +CurlInputStream::StartRequest() +{ request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get()); request->Start(); @@ -393,6 +409,7 @@ CurlInputStream::SeekInternal(offset_type new_offset) } InitEasy(); + StartRequest(); /* send the "Range" header */ @@ -428,6 +445,7 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond) try { BlockingCall(io_thread_get(), [c](){ c->InitEasy(); + c->StartRequest(); }); } catch (...) { delete c; |