client: set content type header on requests

this got lost with the recent refactoring

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-08-25 08:56:32 +02:00
parent 6286ff4eeb
commit f20f9bb9f7

View File

@ -204,10 +204,16 @@ impl Client {
uri: Uri,
json_body: Option<String>,
) -> Result<HttpApiResponse, Error> {
let request = auth
.set_auth_headers(Request::builder().method(method).uri(uri))
.body(json_body.unwrap_or_default().into())
.map_err(|err| Error::internal("failed to build request", err))?;
let request = auth.set_auth_headers(Request::builder().method(method).uri(uri));
let request = if let Some(body) = json_body {
request
.header(http::header::CONTENT_TYPE, "application/json")
.body(body.into())
} else {
request.body(Default::default())
}
.map_err(|err| Error::internal("failed to build request", err))?;
let response = client.request(request).await.map_err(Error::Anyhow)?;