From 63ebc48b69223b401647d08cc8db2834a718bffb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Sep 2024 09:15:56 +0200 Subject: [PATCH] content_encoding: avoid getting all encodings unless necessary The error_do_write() function may very well return witout needing the listing of all encoding types so postpone that call until it is needed. Closes #14831 --- lib/content_encoding.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 734547d006..c0b97f1f7d 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -909,18 +909,18 @@ static CURLcode error_do_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - char all[256]; - (void)Curl_all_content_encodings(all, sizeof(all)); - (void) writer; (void) buf; (void) nbytes; if(!(type & CLIENTWRITE_BODY) || !nbytes) return Curl_cwriter_write(data, writer->next, type, buf, nbytes); - - failf(data, "Unrecognized content encoding type. " - "libcurl understands %s content encodings.", all); + else { + char all[256]; + (void)Curl_all_content_encodings(all, sizeof(all)); + failf(data, "Unrecognized content encoding type. " + "libcurl understands %s content encodings.", all); + } return CURLE_BAD_CONTENT_ENCODING; } -- 2.47.3