input/curl: move code to StartRequest()
This commit is contained in:
parent
d8e4705dd4
commit
ff162b5a03
@ -85,8 +85,19 @@ struct CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
|
|||||||
|
|
||||||
static InputStream *Open(const char *url, Mutex &mutex, Cond &cond);
|
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();
|
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
|
* Frees the current "libcurl easy" handle, and everything
|
||||||
* associated with it.
|
* associated with it.
|
||||||
@ -371,6 +382,11 @@ CurlInputStream::InitEasy()
|
|||||||
|
|
||||||
request_headers.Clear();
|
request_headers.Clear();
|
||||||
request_headers.Append("Icy-Metadata: 1");
|
request_headers.Append("Icy-Metadata: 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CurlInputStream::StartRequest()
|
||||||
|
{
|
||||||
request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||||
|
|
||||||
request->Start();
|
request->Start();
|
||||||
@ -393,6 +409,7 @@ CurlInputStream::SeekInternal(offset_type new_offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
InitEasy();
|
InitEasy();
|
||||||
|
StartRequest();
|
||||||
|
|
||||||
/* send the "Range" header */
|
/* send the "Range" header */
|
||||||
|
|
||||||
@ -428,6 +445,7 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
|
|||||||
try {
|
try {
|
||||||
BlockingCall(io_thread_get(), [c](){
|
BlockingCall(io_thread_get(), [c](){
|
||||||
c->InitEasy();
|
c->InitEasy();
|
||||||
|
c->StartRequest();
|
||||||
});
|
});
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
delete c;
|
delete c;
|
||||||
|
Loading…
Reference in New Issue
Block a user