mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-14 21:46:29 +03:00
Merge branch 'fixhead' into 'next'
fix: HEAD requests should continue to produce METHOD_NOT_ALLOWED See merge request famedly/conduit!402
This commit is contained in:
commit
c61914c8e1
2 changed files with 13 additions and 7 deletions
|
@ -904,7 +904,7 @@ async fn sync_helper(
|
||||||
let leave_shortstatekey = services()
|
let leave_shortstatekey = services()
|
||||||
.rooms
|
.rooms
|
||||||
.short
|
.short
|
||||||
.get_or_create_shortstatekey(&StateEventType::RoomMember, &sender_user.as_str())?;
|
.get_or_create_shortstatekey(&StateEventType::RoomMember, sender_user.as_str())?;
|
||||||
|
|
||||||
left_state_ids.insert(leave_shortstatekey, left_event_id);
|
left_state_ids.insert(leave_shortstatekey, left_event_id);
|
||||||
|
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -24,10 +24,13 @@ use figment::{
|
||||||
};
|
};
|
||||||
use http::{
|
use http::{
|
||||||
header::{self, HeaderName},
|
header::{self, HeaderName},
|
||||||
Method, Uri,
|
Method, StatusCode, Uri,
|
||||||
};
|
};
|
||||||
use opentelemetry::trace::{FutureExt, Tracer};
|
use opentelemetry::trace::{FutureExt, Tracer};
|
||||||
use ruma::api::{client::error::ErrorKind, IncomingRequest};
|
use ruma::api::{
|
||||||
|
client::{error::Error as RumaError, error::ErrorKind, uiaa::UiaaResponse},
|
||||||
|
IncomingRequest,
|
||||||
|
};
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tower_http::{
|
use tower_http::{
|
||||||
|
@ -197,15 +200,18 @@ async fn run_server() -> io::Result<()> {
|
||||||
async fn unrecognized_method<B>(
|
async fn unrecognized_method<B>(
|
||||||
req: axum::http::Request<B>,
|
req: axum::http::Request<B>,
|
||||||
next: axum::middleware::Next<B>,
|
next: axum::middleware::Next<B>,
|
||||||
) -> std::result::Result<axum::response::Response, axum::http::StatusCode> {
|
) -> std::result::Result<axum::response::Response, StatusCode> {
|
||||||
let method = req.method().clone();
|
let method = req.method().clone();
|
||||||
let uri = req.uri().clone();
|
let uri = req.uri().clone();
|
||||||
let inner = next.run(req).await;
|
let inner = next.run(req).await;
|
||||||
if inner.status() == axum::http::StatusCode::METHOD_NOT_ALLOWED {
|
if inner.status() == axum::http::StatusCode::METHOD_NOT_ALLOWED {
|
||||||
warn!("Method not allowed: {method} {uri}");
|
warn!("Method not allowed: {method} {uri}");
|
||||||
return Ok(
|
return Ok(RumaResponse(UiaaResponse::MatrixError(RumaError {
|
||||||
Error::BadRequest(ErrorKind::Unrecognized, "Unrecognized request").into_response(),
|
kind: ErrorKind::Unrecognized,
|
||||||
);
|
message: "M_UNRECOGNIZED: Unrecognized request".to_owned(),
|
||||||
|
status_code: StatusCode::METHOD_NOT_ALLOWED,
|
||||||
|
}))
|
||||||
|
.into_response());
|
||||||
}
|
}
|
||||||
Ok(inner)
|
Ok(inner)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue