Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
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
Maunium
synapse
Commits
2901f543
Unverified
Commit
2901f543
authored
4 years ago
by
Erik Johnston
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix missing CORS headers on OPTION responses (#7560)
Broke in #7534.
parent
e5c67d04
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/7560.misc
+1
-0
1 addition, 0 deletions
changelog.d/7560.misc
synapse/http/server.py
+1
-1
1 addition, 1 deletion
synapse/http/server.py
tests/test_server.py
+28
-0
28 additions, 0 deletions
tests/test_server.py
with
30 additions
and
1 deletion
changelog.d/7560.misc
0 → 100644
+
1
−
0
View file @
2901f543
All endpoints now respond with a 200 OK for `OPTIONS` requests.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/http/server.py
+
1
−
1
View file @
2901f543
...
...
@@ -452,7 +452,7 @@ class OptionsResource(resource.Resource):
code
,
response_json_object
=
_options_handler
(
request
)
return
respond_with_json
(
request
,
code
,
response_json_object
,
send_cors
=
Fals
e
,
canonical_json
=
False
,
request
,
code
,
response_json_object
,
send_cors
=
Tru
e
,
canonical_json
=
False
,
)
def
getChildWithDefault
(
self
,
path
,
request
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_server.py
+
28
−
0
View file @
2901f543
...
...
@@ -203,12 +203,40 @@ class OptionsResourceTests(unittest.TestCase):
self
.
assertEqual
(
channel
.
result
[
"
code
"
],
b
"
200
"
)
self
.
assertEqual
(
channel
.
result
[
"
body
"
],
b
"
{}
"
)
# Ensure the correct CORS headers have been added
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Origin
"
),
"
has CORS Origin header
"
,
)
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Methods
"
),
"
has CORS Methods header
"
,
)
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Headers
"
),
"
has CORS Headers header
"
,
)
def
test_known_options_request
(
self
):
"""
An OPTIONS requests to an known URL still returns 200 OK.
"""
channel
=
self
.
_make_request
(
b
"
OPTIONS
"
,
b
"
/res/
"
)
self
.
assertEqual
(
channel
.
result
[
"
code
"
],
b
"
200
"
)
self
.
assertEqual
(
channel
.
result
[
"
body
"
],
b
"
{}
"
)
# Ensure the correct CORS headers have been added
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Origin
"
),
"
has CORS Origin header
"
,
)
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Methods
"
),
"
has CORS Methods header
"
,
)
self
.
assertTrue
(
channel
.
headers
.
hasHeader
(
b
"
Access-Control-Allow-Headers
"
),
"
has CORS Headers header
"
,
)
def
test_unknown_request
(
self
):
"""
A non-OPTIONS request to an unknown URL should 404.
"""
channel
=
self
.
_make_request
(
b
"
GET
"
,
b
"
/foo/
"
)
...
...
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