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:
parent
6286ff4eeb
commit
f20f9bb9f7
@ -204,10 +204,16 @@ impl Client {
|
|||||||
uri: Uri,
|
uri: Uri,
|
||||||
json_body: Option<String>,
|
json_body: Option<String>,
|
||||||
) -> Result<HttpApiResponse, Error> {
|
) -> Result<HttpApiResponse, Error> {
|
||||||
let request = auth
|
let request = auth.set_auth_headers(Request::builder().method(method).uri(uri));
|
||||||
.set_auth_headers(Request::builder().method(method).uri(uri))
|
|
||||||
.body(json_body.unwrap_or_default().into())
|
let request = if let Some(body) = json_body {
|
||||||
.map_err(|err| Error::internal("failed to build request", err))?;
|
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)?;
|
let response = client.request(request).await.map_err(Error::Anyhow)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user