api: Fix inverse condition for sending application/json content-type
This commit is contained in:
parent
21e4c90cfa
commit
7df5a0f09d
@ -102,14 +102,14 @@ impl Request {
|
||||
// policies that don't allow the `Content-Type` header (for things such as `.well-known`
|
||||
// that are commonly handled by something else than a homeserver).
|
||||
let mut header_kvs = if self.raw_body_field().is_some() || self.has_body_fields() {
|
||||
TokenStream::new()
|
||||
} else {
|
||||
quote! {
|
||||
req_headers.insert(
|
||||
#http::header::CONTENT_TYPE,
|
||||
#http::header::HeaderValue::from_static("application/json"),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
TokenStream::new()
|
||||
};
|
||||
|
||||
header_kvs.extend(self.header_fields().map(|request_field| {
|
||||
|
@ -1,7 +1,5 @@
|
||||
# [unreleased]
|
||||
|
||||
# 0.18.4
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* Stop adding a `Content-Type` header to requests without any fields
|
||||
@ -9,6 +7,10 @@ Bug fixes:
|
||||
environment if the server isn't configured to allow that header for
|
||||
cross-origin requests
|
||||
|
||||
# 0.18.4
|
||||
|
||||
Yanked.
|
||||
|
||||
# 0.18.3
|
||||
|
||||
Improvements:
|
||||
|
14
crates/ruma-client-api/tests/headers.rs
Normal file
14
crates/ruma-client-api/tests/headers.rs
Normal file
@ -0,0 +1,14 @@
|
||||
#![cfg(feature = "client")]
|
||||
|
||||
use http::HeaderMap;
|
||||
use ruma_api::{OutgoingRequest as _, SendAccessToken};
|
||||
use ruma_client_api::unversioned::discover_homeserver;
|
||||
|
||||
#[test]
|
||||
fn get_request_headers() {
|
||||
let req: http::Request<Vec<u8>> = discover_homeserver::Request::new()
|
||||
.try_into_http_request("https://homeserver.tld", SendAccessToken::None)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(*req.headers(), HeaderMap::default());
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user