diff --git a/ent/encryption/azure_host.cc b/ent/encryption/azure_host.cc index 951f9d98c7..fa9c0016ad 100644 --- a/ent/encryption/azure_host.cc +++ b/ent/encryption/azure_host.cc @@ -399,8 +399,7 @@ future azure_host::impl::send_request(const sstring& host, unsigne client.target(path); client.method(httpd::operation_type::POST); client.add_header("Authorization", fmt::format("Bearer {}", token.token)); - client.add_header("Content-Type", "application/json"); - client.content(std::move(rjson::print(body))); + client.content("application/json", std::move(rjson::print(body))); azlog.trace("Sending request: {}", rest::redacted_request_type{ client.request(), filter }); diff --git a/ent/encryption/kms_host.cc b/ent/encryption/kms_host.cc index e7d9f9d3ae..5a47fffbc6 100644 --- a/ent/encryption/kms_host.cc +++ b/ent/encryption/kms_host.cc @@ -808,7 +808,7 @@ future encryption::kms_host::impl::post client.add_header(AWS_AUTHORIZATION_HEADER, awsAuthString); client.target("/"); - client.content(query.content); + client.content(query.content_type, query.content); client.method(httpclient::method_type::POST); kms_log.trace("Request: {}", client.request()); diff --git a/seastar b/seastar index c2d9893334..b6be384e5d 160000 --- a/seastar +++ b/seastar @@ -1 +1 @@ -Subproject commit c2d989333468cc2d010ecef6c5b724faf542fe2f +Subproject commit b6be384e5d06b69edbc0d06e64c78d4f2a5437dd diff --git a/utils/azure/identity/service_principal_credentials.cc b/utils/azure/identity/service_principal_credentials.cc index 5c03fa1bb1..00512d4f15 100644 --- a/utils/azure/identity/service_principal_credentials.cc +++ b/utils/azure/identity/service_principal_credentials.cc @@ -170,8 +170,7 @@ future service_principal_credentials::post(const sstring& body) { rest::httpclient client{_host, _port, std::move(creds), options}; client.target(path); client.method(op); - client.add_header("Content-Type", mime_type); - client.content(std::move(body)); + client.content(mime_type, std::move(body)); if (az_creds_logger.is_enabled(log_level::trace)) { az_creds_logger.trace("[{}] Sending request: {}", *this, rest::redacted_request_type{ client.request(), filter }); diff --git a/utils/gcp/object_storage.cc b/utils/gcp/object_storage.cc index e73d574359..2b65e7c700 100644 --- a/utils/gcp/object_storage.cc +++ b/utils/gcp/object_storage.cc @@ -294,13 +294,9 @@ utils::gcp::storage::client::impl::send_with_retry(const std::string& path, cons req.add_header(k, v); } - if (!content_type.empty()) { - req.add_header(httpclient::CONTENT_TYPE_HEADER, content_type); - } - std::visit(overloaded_functor { - [&](const std::string& s) { req.content(s); }, - [&](const writer_and_size& ws) { req.content(ws.first, ws.second); } + [&](const std::string& s) { req.content(content_type, s); }, + [&](const writer_and_size& ws) { req.content(content_type, ws.first, ws.second); } }, body); // GCP storage requires this even if content is empty diff --git a/utils/rest/client.cc b/utils/rest/client.cc index 298e7ae419..61d29bb37c 100644 --- a/utils/rest/client.cc +++ b/utils/rest/client.cc @@ -39,14 +39,12 @@ void rest::request_wrapper::method(method_type type) { _req._method = httpd::type2str(type); } -void rest::request_wrapper::content(std::string_view content) { - _req.content_length = content.size(); - _req.content = sstring(content); +void rest::request_wrapper::content(std::string_view content_type, std::string_view content) { + _req.write_body(sstring(content_type), sstring(content)); } -void rest::request_wrapper::content(body_writer w, size_t len) { - _req.content_length = len; - _req.body_writer = std::move(w); +void rest::request_wrapper::content(std::string_view content_type, body_writer w, size_t len) { + _req.write_body(sstring(content_type), len, std::move(w)); } void rest::request_wrapper::target(std::string_view s) { @@ -219,8 +217,7 @@ future<> rest::send_request(std::string_view uri if (content_type.empty()) { content_type = "application/x-www-form-urlencoded"; } - client.content(std::move(body)); - client.add_header(httpclient::CONTENT_TYPE_HEADER, content_type); + client.content(content_type, std::move(body)); } co_await client.send([&] (const http::reply& rep, std::string_view result) { diff --git a/utils/rest/client.hh b/utils/rest/client.hh index f4c390010b..a2e6408a2b 100644 --- a/utils/rest/client.hh +++ b/utils/rest/client.hh @@ -41,8 +41,8 @@ public: using body_writer = decltype(std::declval().body_writer); void method(method_type); - void content(std::string_view); - void content(body_writer, size_t); + void content(std::string_view content_type, std::string_view); + void content(std::string_view content_type, body_writer, size_t); void target(std::string_view);