mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-28 05:04:16 -05:00
[http/spotify] Add support for http sessions across multiple requests
This change allows to reuse curl handles for multiple requests. Reusing a curl handle improves performance if more than one request is made against a service (connection, session cache, dns cache are kept between requests).
This commit is contained in:
13
src/http.h
13
src/http.h
@@ -4,10 +4,16 @@
|
||||
|
||||
#include <event2/buffer.h>
|
||||
#include <event2/http.h>
|
||||
#include <curl/curl.h>
|
||||
#include "misc.h"
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
struct http_client_session
|
||||
{
|
||||
CURL *curl;
|
||||
};
|
||||
|
||||
struct http_client_ctx
|
||||
{
|
||||
/* Destination URL, header and body of outgoing request body. If output_body
|
||||
@@ -54,6 +60,11 @@ struct http_icy_metadata
|
||||
uint32_t hash;
|
||||
};
|
||||
|
||||
void
|
||||
http_client_session_init(struct http_client_session *session);
|
||||
|
||||
void
|
||||
http_client_session_deinit(struct http_client_session *session);
|
||||
|
||||
/* Make a http(s) request. We use libcurl to make https requests. We could use
|
||||
* libevent and avoid the dependency, but for SSL, libevent needs to be v2.1
|
||||
@@ -63,7 +74,7 @@ struct http_icy_metadata
|
||||
* @return 0 if successful, -1 if an error occurred (e.g. no libcurl)
|
||||
*/
|
||||
int
|
||||
http_client_request(struct http_client_ctx *ctx);
|
||||
http_client_request(struct http_client_ctx *ctx, struct http_client_session *session);
|
||||
|
||||
|
||||
/* Converts the keyval dictionary to a application/x-www-form-urlencoded string.
|
||||
|
||||
Reference in New Issue
Block a user