Set Content-Type to application/json in all manual endpoint trait implementations

This commit is contained in:
Akshay 2021-03-01 23:09:12 +05:30 committed by GitHub
parent 4ced423612
commit c27e66741a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -121,7 +121,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
base_url: &str,
access_token: Option<&str>,
) -> Result<http::Request<Vec<u8>>, IntoHttpError> {
use http::header::{HeaderValue, AUTHORIZATION};
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
let http_request = http::Request::builder()
@ -145,6 +145,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
access_token.ok_or(IntoHttpError::NeedsAuthentication)?
))?,
)
.header(CONTENT_TYPE, "application/json")
.body(serde_json::to_vec(&self.content)?)?;
Ok(http_request)

View File

@ -114,7 +114,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
base_url: &str,
access_token: Option<&str>,
) -> Result<http::Request<Vec<u8>>, IntoHttpError> {
use http::header::{HeaderValue, AUTHORIZATION};
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
let http_request = http::Request::builder()
@ -137,6 +137,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
access_token.ok_or(IntoHttpError::NeedsAuthentication)?
))?,
)
.header(CONTENT_TYPE, "application/json")
.body(serde_json::to_vec(&self.content)?)?;
Ok(http_request)

View File

@ -117,7 +117,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
base_url: &str,
access_token: Option<&str>,
) -> Result<http::Request<Vec<u8>>, IntoHttpError> {
use http::header::{HeaderValue, AUTHORIZATION};
use http::header::{HeaderValue, AUTHORIZATION, CONTENT_TYPE};
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
let http_request = http::Request::builder()
@ -141,6 +141,7 @@ impl<'a> ruma_api::OutgoingRequest for Request<'a> {
access_token.ok_or(IntoHttpError::NeedsAuthentication)?
))?,
)
.header(CONTENT_TYPE, "application/json")
.body(serde_json::to_vec(&self.content)?)?;
Ok(http_request)