Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
7c98ba64
Unverified
Commit
7c98ba64
authored
2 years ago
by
Timo Kösters
Browse files
Options
Downloads
Patches
Plain Diff
fix: HEAD requests should produce METHOD_NOT_ALLOWED
parent
2231a69b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/client_server/directory.rs
+2
-9
2 additions, 9 deletions
src/api/client_server/directory.rs
src/api/client_server/sync.rs
+1
-1
1 addition, 1 deletion
src/api/client_server/sync.rs
src/main.rs
+12
-6
12 additions, 6 deletions
src/main.rs
with
15 additions
and
16 deletions
src/api/client_server/directory.rs
+
2
−
9
View file @
7c98ba64
...
...
@@ -87,10 +87,7 @@ pub async fn set_room_visibility_route(
if
!
services
()
.rooms.metadata
.exists
(
&
body
.room_id
)
?
{
// Return 404 if the room doesn't exist
return
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room not found"
,
));
return
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room not found"
));
}
match
&
body
.visibility
{
...
...
@@ -116,13 +113,9 @@ pub async fn set_room_visibility_route(
pub
async
fn
get_room_visibility_route
(
body
:
Ruma
<
get_room_visibility
::
v3
::
IncomingRequest
>
,
)
->
Result
<
get_room_visibility
::
v3
::
Response
>
{
if
!
services
()
.rooms.metadata
.exists
(
&
body
.room_id
)
?
{
// Return 404 if the room doesn't exist
return
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room not found"
,
));
return
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room not found"
));
}
Ok
(
get_room_visibility
::
v3
::
Response
{
...
...
This diff is collapsed.
Click to expand it.
src/api/client_server/sync.rs
+
1
−
1
View file @
7c98ba64
...
...
@@ -905,7 +905,7 @@ async fn sync_helper(
let
leave_shortstatekey
=
services
()
.rooms
.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
);
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
12
−
6
View file @
7c98ba64
...
...
@@ -24,10 +24,13 @@
};
use
http
::{
header
::{
self
,
HeaderName
},
Method
,
Uri
,
Method
,
StatusCode
,
Uri
,
};
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
tower
::
ServiceBuilder
;
use
tower_http
::{
...
...
@@ -191,15 +194,18 @@ async fn run_server() -> io::Result<()> {
async
fn
unrecognized_method
<
B
>
(
req
:
axum
::
http
::
Request
<
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
uri
=
req
.uri
()
.clone
();
let
inner
=
next
.run
(
req
)
.await
;
if
inner
.status
()
==
axum
::
http
::
StatusCode
::
METHOD_NOT_ALLOWED
{
warn!
(
"Method not allowed: {method} {uri}"
);
return
Ok
(
Error
::
BadRequest
(
ErrorKind
::
Unrecognized
,
"Unrecognized request"
)
.into_response
(),
);
return
Ok
(
RumaResponse
(
UiaaResponse
::
MatrixError
(
RumaError
{
kind
:
ErrorKind
::
Unrecognized
,
message
:
"M_UNRECOGNIZED: Unrecognized request"
.to_owned
(),
status_code
:
StatusCode
::
METHOD_NOT_ALLOWED
,
}))
.into_response
());
}
Ok
(
inner
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment