1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Layer to application/x-www-form-urlencoded bodies

This commit is contained in:
Quentin Gliech
2022-08-12 16:49:54 +02:00
parent 398379e21b
commit d94442f972
7 changed files with 142 additions and 8 deletions

View File

@@ -19,7 +19,8 @@ use futures_util::{
future::{Either, MapErr},
FutureExt, TryFutureExt,
};
use http::{header::CONTENT_TYPE, HeaderValue, Request};
use headers::{ContentType, HeaderMapExt};
use http::Request;
use http_body::Full;
use serde::Serialize;
use thiserror::Error;
@@ -83,9 +84,7 @@ where
fn call(&mut self, request: Request<T>) -> Self::Future {
let (mut parts, body) = request.into_parts();
parts
.headers
.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
parts.headers.typed_insert(ContentType::json());
let body = match serde_json::to_vec(&body) {
Ok(body) => Full::new(Bytes::from(body)),