Commit 714e69e7 authored by Max Kellermann's avatar Max Kellermann

input/qobuz: create JSON parser on demand

parent cb87ed29
...@@ -82,7 +82,6 @@ QobuzLoginRequest::QobuzLoginRequest(CurlGlobal &curl, ...@@ -82,7 +82,6 @@ QobuzLoginRequest::QobuzLoginRequest(CurlGlobal &curl,
const char *device_manufacturer_id, const char *device_manufacturer_id,
QobuzLoginHandler &_handler) noexcept QobuzLoginHandler &_handler) noexcept
:request(curl, *this), :request(curl, *this),
parser(&parse_callbacks, nullptr, this),
handler(_handler) handler(_handler)
{ {
request.SetUrl(MakeLoginUrl(request.Get(), base_url, app_id, request.SetUrl(MakeLoginUrl(request.Get(), base_url, app_id,
...@@ -105,6 +104,8 @@ QobuzLoginRequest::OnHeaders(unsigned status, ...@@ -105,6 +104,8 @@ QobuzLoginRequest::OnHeaders(unsigned status,
auto i = headers.find("content-type"); auto i = headers.find("content-type");
if (i == headers.end() || i->second.find("/json") == i->second.npos) if (i == headers.end() || i->second.find("/json") == i->second.npos)
throw std::runtime_error("Not a JSON response from Qobuz"); throw std::runtime_error("Not a JSON response from Qobuz");
parser = {&parse_callbacks, nullptr, this};
} }
void void
......
...@@ -55,7 +55,6 @@ QobuzTrackRequest::QobuzTrackRequest(QobuzClient &client, ...@@ -55,7 +55,6 @@ QobuzTrackRequest::QobuzTrackRequest(QobuzClient &client,
:request(client.GetCurl(), :request(client.GetCurl(),
MakeTrackUrl(client, track_id).c_str(), MakeTrackUrl(client, track_id).c_str(),
*this), *this),
parser(&parse_callbacks, nullptr, this),
handler(_handler) handler(_handler)
{ {
request_headers.Append(("X-User-Auth-Token:" request_headers.Append(("X-User-Auth-Token:"
...@@ -78,6 +77,8 @@ QobuzTrackRequest::OnHeaders(unsigned status, ...@@ -78,6 +77,8 @@ QobuzTrackRequest::OnHeaders(unsigned status,
auto i = headers.find("content-type"); auto i = headers.find("content-type");
if (i == headers.end() || i->second.find("/json") == i->second.npos) if (i == headers.end() || i->second.find("/json") == i->second.npos)
throw std::runtime_error("Not a JSON response from Qobuz"); throw std::runtime_error("Not a JSON response from Qobuz");
parser = {&parse_callbacks, nullptr, this};
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment