mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-29 05:19:05 -05:00
[http] Support for extracting artwork url from within StreamUrl field
This commit is contained in:
committed by
Alain Nussbaumer
parent
6c7b568e49
commit
3c98ca7928
36
src/http.c
36
src/http.c
@@ -36,6 +36,7 @@
|
||||
#include <libavutil/opt.h>
|
||||
|
||||
#include <event2/event.h>
|
||||
#include <event2/keyvalq_struct.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
@@ -193,6 +194,41 @@ http_client_request(struct http_client_ctx *ctx, struct http_client_session *ses
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
http_form_urldecode(struct keyval *kv, const char *uri)
|
||||
{
|
||||
struct evhttp_uri *ev_uri = NULL;
|
||||
struct evkeyvalq ev_query = { 0 };
|
||||
struct evkeyval *param;
|
||||
const char *query;
|
||||
int ret;
|
||||
|
||||
ev_uri = evhttp_uri_parse_with_flags(uri, EVHTTP_URI_NONCONFORMANT);
|
||||
if (!ev_uri)
|
||||
return -1;
|
||||
|
||||
query = evhttp_uri_get_query(ev_uri);
|
||||
if (!query)
|
||||
goto error;
|
||||
|
||||
ret = evhttp_parse_query_str(query, &ev_query);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
// musl libc doesn't have sys/queue.h so don't use TAILQ_FOREACH
|
||||
for (param = ev_query.tqh_first; param; param = param->next.tqe_next)
|
||||
keyval_add(kv, param->key, param->value);
|
||||
|
||||
evhttp_uri_free(ev_uri);
|
||||
evhttp_clear_headers(&ev_query);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
evhttp_uri_free(ev_uri);
|
||||
evhttp_clear_headers(&ev_query);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *
|
||||
http_form_urlencode(struct keyval *kv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user