api: Allow incoming request method of HEAD for GET endpoints

This commit is contained in:
Jonas Platte 2022-11-02 23:26:57 +01:00
parent 3eb82950f2
commit 8d0f817f48
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -176,7 +176,10 @@ impl Request {
B: ::std::convert::AsRef<[::std::primitive::u8]>, B: ::std::convert::AsRef<[::std::primitive::u8]>,
S: ::std::convert::AsRef<::std::primitive::str>, S: ::std::convert::AsRef<::std::primitive::str>,
{ {
if request.method() != METADATA.method { if !(request.method() == METADATA.method
|| request.method() == #http::Method::HEAD
&& METADATA.method == #http::Method::GET)
{
return Err(#ruma_common::api::error::FromHttpRequestError::MethodMismatch { return Err(#ruma_common::api::error::FromHttpRequestError::MethodMismatch {
expected: METADATA.method, expected: METADATA.method,
received: request.method().clone(), received: request.method().clone(),