From 6b661a91c6dc2db3bc47b1da5775bb4f090ec350 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Mon, 17 Feb 2025 21:05:18 +0900 Subject: [PATCH] RequestServer: Send empty headers in requests --- Services/RequestServer/ConnectionFromClient.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Services/RequestServer/ConnectionFromClient.cpp b/Services/RequestServer/ConnectionFromClient.cpp index 136b31e1d01..2b204999e4e 100644 --- a/Services/RequestServer/ConnectionFromClient.cpp +++ b/Services/RequestServer/ConnectionFromClient.cpp @@ -433,6 +433,18 @@ void ConnectionFromClient::start_request(i32 request_id, ByteString const& metho curl_headers = curl_slist_append(curl_headers, "Content-Type:"); for (auto const& header : request_headers.headers()) { + if (header.value.is_empty()) { + // Special case for headers with an empty value. curl will discard the header unless we pass the + // header name followed by a semicolon. + // + // i.e. we need to pass "Content-Type;" instead of "Content-Type: " + // + // See: https://curl.se/libcurl/c/httpcustomheader.html + auto header_string = ByteString::formatted("{};", header.name); + curl_headers = curl_slist_append(curl_headers, header_string.characters()); + continue; + } + auto header_string = ByteString::formatted("{}: {}", header.name, header.value); curl_headers = curl_slist_append(curl_headers, header_string.characters()); }