mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-30 05:41:03 -05:00
[artwork/http] Check response code and content type
Extends the http_client_ctx to hold the response code for a request. Also adds the content type header, if it was a https request (using libcurl instead of libevent)
This commit is contained in:
@@ -206,7 +206,7 @@ static struct artwork_source artwork_item_source[] =
|
||||
.name = "Spotify web api",
|
||||
.handler = source_item_spotifywebapi_get,
|
||||
.data_kinds = (1 << DATA_KIND_SPOTIFY),
|
||||
.cache = ON_SUCCESS,
|
||||
.cache = ON_SUCCESS | ON_FAILURE,
|
||||
},
|
||||
{
|
||||
.name = "playlist own",
|
||||
@@ -261,13 +261,14 @@ artwork_url_read(struct evbuffer *evbuf, const char *url)
|
||||
if (http_client_request(&client) < 0)
|
||||
goto out_kv;
|
||||
|
||||
if (client.response_code != HTTP_OK)
|
||||
goto out_kv;
|
||||
|
||||
content_type = keyval_get(kv, "Content-Type");
|
||||
if (content_type && (strcmp(content_type, "image/jpeg") == 0))
|
||||
ret = ART_FMT_JPEG;
|
||||
else if (content_type && (strcmp(content_type, "image/png") == 0))
|
||||
ret = ART_FMT_PNG;
|
||||
else
|
||||
ret = ART_FMT_JPEG;
|
||||
|
||||
out_kv:
|
||||
keyval_clear(kv);
|
||||
|
||||
Reference in New Issue
Block a user