From 9283d0c3c20af7abfdbf64e0be42679b874e124e Mon Sep 17 00:00:00 2001 From: Christian Meffert Date: Sun, 26 Jan 2025 05:55:47 +0000 Subject: [PATCH] [http] Make output_body (request body) in http_client_ctx "const" and delete unused fields --- src/http.h | 6 +----- src/lastfm.c | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/http.h b/src/http.h index a68c5d97..6b9e05ec 100644 --- a/src/http.h +++ b/src/http.h @@ -21,7 +21,7 @@ struct http_client_ctx */ const char *url; struct keyval *output_headers; - char *output_body; + const char *output_body; /* A keyval/evbuf to store response headers and body. * Can be set to NULL to ignore that part of the response. @@ -37,10 +37,6 @@ struct http_client_ctx /* HTTP Response code */ int response_code; - - /* Private */ - int ret; - void *evbase; }; struct http_icy_metadata diff --git a/src/lastfm.c b/src/lastfm.c index 0a75c33f..a33b9402 100644 --- a/src/lastfm.c +++ b/src/lastfm.c @@ -233,6 +233,7 @@ static int request_post(const char *url, struct keyval *kv, char **errmsg) { struct http_client_ctx ctx; + char *request_body; int ret; // API requires that we MD5 sign sorted param (without "format" param) @@ -245,13 +246,14 @@ request_post(const char *url, struct keyval *kv, char **errmsg) memset(&ctx, 0, sizeof(struct http_client_ctx)); - ctx.output_body = http_form_urlencode(kv); - if (!ctx.output_body) + request_body = http_form_urlencode(kv); + if (!request_body) { DPRINTF(E_LOG, L_LASTFM, "Aborting request, http_form_urlencode failed\n"); return -1; } + ctx.output_body = request_body; ctx.url = url; ctx.input_body = evbuffer_new(); @@ -262,7 +264,7 @@ request_post(const char *url, struct keyval *kv, char **errmsg) ret = response_process(&ctx, errmsg); out_free_ctx: - free(ctx.output_body); + free(request_body); evbuffer_free(ctx.input_body); return ret;