mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-10 05:08:11 -05:00
[http] Use curl for URL parsing instead of depending on httpd
Makes it easier to make the httpd parsing internal.
This commit is contained in:
parent
e0d3908a12
commit
e8750e9350
28
src/http.c
28
src/http.c
@ -40,7 +40,6 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "httpd.h"
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "conffile.h"
|
#include "conffile.h"
|
||||||
@ -240,9 +239,11 @@ http_form_urlencode(struct keyval *kv)
|
|||||||
int
|
int
|
||||||
http_stream_setup(char **stream, const char *url)
|
http_stream_setup(char **stream, const char *url)
|
||||||
{
|
{
|
||||||
|
CURLU *url_handle;
|
||||||
|
CURLUcode rc;
|
||||||
struct http_client_ctx ctx;
|
struct http_client_ctx ctx;
|
||||||
struct httpd_uri_parsed *parsed;
|
|
||||||
struct evbuffer *evbuf;
|
struct evbuffer *evbuf;
|
||||||
|
char *path;
|
||||||
const char *ext;
|
const char *ext;
|
||||||
char *line;
|
char *line;
|
||||||
char *pos;
|
char *pos;
|
||||||
@ -253,17 +254,28 @@ http_stream_setup(char **stream, const char *url)
|
|||||||
|
|
||||||
*stream = NULL;
|
*stream = NULL;
|
||||||
|
|
||||||
parsed = httpd_uri_parse(url);
|
CHECK_NULL(L_HTTP, url_handle = curl_url());
|
||||||
if (!parsed)
|
|
||||||
|
rc = curl_url_set(url_handle, CURLUPART_URL, url, 0);
|
||||||
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_HTTP, "Couldn't parse internet playlist: '%s'\n", url);
|
DPRINTF(E_LOG, L_HTTP, "Couldn't parse internet playlist: '%s'\n", url);
|
||||||
|
curl_url_cleanup(url_handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsed->path does not include query or fragment, so should work with any url's
|
rc = curl_url_get(url_handle, CURLUPART_PATH, &path, 0);
|
||||||
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_HTTP, "Couldn't find internet playlist path: '%s'\n", url);
|
||||||
|
curl_url_cleanup(url_handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// path does not include query or fragment, so should work with any url's
|
||||||
// e.g. http://yp.shoutcast.com/sbin/tunein-station.pls?id=99179772#Air Jazz
|
// e.g. http://yp.shoutcast.com/sbin/tunein-station.pls?id=99179772#Air Jazz
|
||||||
pl_format = PLAYLIST_UNK;
|
pl_format = PLAYLIST_UNK;
|
||||||
if (parsed->path && (ext = strrchr(parsed->path, '.')))
|
if (path && (ext = strrchr(path, '.')))
|
||||||
{
|
{
|
||||||
if (strcasecmp(ext, ".m3u") == 0)
|
if (strcasecmp(ext, ".m3u") == 0)
|
||||||
pl_format = PLAYLIST_M3U;
|
pl_format = PLAYLIST_M3U;
|
||||||
@ -271,7 +283,9 @@ http_stream_setup(char **stream, const char *url)
|
|||||||
pl_format = PLAYLIST_PLS;
|
pl_format = PLAYLIST_PLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
httpd_uri_free(parsed);
|
curl_free(path);
|
||||||
|
curl_url_cleanup(url_handle);
|
||||||
|
|
||||||
|
|
||||||
if (pl_format==PLAYLIST_UNK)
|
if (pl_format==PLAYLIST_UNK)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user