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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
84cf3e47
Unverified
Commit
84cf3e47
authored
3 years ago
by
Erik Johnston
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow response of `/send_join` to be larger. (#10093)
Fixes #10087.
parent
8e15c92c
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
changelog.d/10093.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/10093.bugfix
synapse/federation/transport/client.py
+7
-0
7 additions, 0 deletions
synapse/federation/transport/client.py
synapse/http/matrixfederationclient.py
+13
-1
13 additions, 1 deletion
synapse/http/matrixfederationclient.py
with
21 additions
and
1 deletion
changelog.d/10093.bugfix
0 → 100644
+
1
−
0
View file @
84cf3e47
Fix HTTP response size limit to allow joining very large rooms over federation.
This diff is collapsed.
Click to expand it.
synapse/federation/transport/client.py
+
7
−
0
View file @
84cf3e47
...
@@ -35,6 +35,11 @@ from synapse.types import JsonDict
...
@@ -35,6 +35,11 @@ from synapse.types import JsonDict
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
# Send join responses can be huge, so we set a separate limit here. The response
# is parsed in a streaming manner, which helps alleviate the issue of memory
# usage a bit.
MAX_RESPONSE_SIZE_SEND_JOIN
=
500
*
1024
*
1024
class
TransportLayerClient
:
class
TransportLayerClient
:
"""
Sends federation HTTP requests to other servers
"""
"""
Sends federation HTTP requests to other servers
"""
...
@@ -261,6 +266,7 @@ class TransportLayerClient:
...
@@ -261,6 +266,7 @@ class TransportLayerClient:
path
=
path
,
path
=
path
,
data
=
content
,
data
=
content
,
parser
=
SendJoinParser
(
room_version
,
v1_api
=
True
),
parser
=
SendJoinParser
(
room_version
,
v1_api
=
True
),
max_response_size
=
MAX_RESPONSE_SIZE_SEND_JOIN
,
)
)
return
response
return
response
...
@@ -276,6 +282,7 @@ class TransportLayerClient:
...
@@ -276,6 +282,7 @@ class TransportLayerClient:
path
=
path
,
path
=
path
,
data
=
content
,
data
=
content
,
parser
=
SendJoinParser
(
room_version
,
v1_api
=
False
),
parser
=
SendJoinParser
(
room_version
,
v1_api
=
False
),
max_response_size
=
MAX_RESPONSE_SIZE_SEND_JOIN
,
)
)
return
response
return
response
...
...
This diff is collapsed.
Click to expand it.
synapse/http/matrixfederationclient.py
+
13
−
1
View file @
84cf3e47
...
@@ -205,6 +205,7 @@ async def _handle_response(
...
@@ -205,6 +205,7 @@ async def _handle_response(
response
:
IResponse
,
response
:
IResponse
,
start_ms
:
int
,
start_ms
:
int
,
parser
:
ByteParser
[
T
],
parser
:
ByteParser
[
T
],
max_response_size
:
Optional
[
int
]
=
None
,
)
->
T
:
)
->
T
:
"""
"""
Reads the body of a response with a timeout and sends it to a parser
Reads the body of a response with a timeout and sends it to a parser
...
@@ -216,15 +217,20 @@ async def _handle_response(
...
@@ -216,15 +217,20 @@ async def _handle_response(
response: response to the request
response: response to the request
start_ms: Timestamp when request was made
start_ms: Timestamp when request was made
parser: The parser for the response
parser: The parser for the response
max_response_size: The maximum size to read from the response, if None
uses the default.
Returns:
Returns:
The parsed response
The parsed response
"""
"""
if
max_response_size
is
None
:
max_response_size
=
MAX_RESPONSE_SIZE
try
:
try
:
check_content_type_is
(
response
.
headers
,
parser
.
CONTENT_TYPE
)
check_content_type_is
(
response
.
headers
,
parser
.
CONTENT_TYPE
)
d
=
read_body_with_max_size
(
response
,
parser
,
MAX_RESPONSE_SIZE
)
d
=
read_body_with_max_size
(
response
,
parser
,
max_response_size
)
d
=
timeout_deferred
(
d
,
timeout
=
timeout_sec
,
reactor
=
reactor
)
d
=
timeout_deferred
(
d
,
timeout
=
timeout_sec
,
reactor
=
reactor
)
length
=
await
make_deferred_yieldable
(
d
)
length
=
await
make_deferred_yieldable
(
d
)
...
@@ -735,6 +741,7 @@ class MatrixFederationHttpClient:
...
@@ -735,6 +741,7 @@ class MatrixFederationHttpClient:
backoff_on_404
:
bool
=
False
,
backoff_on_404
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
parser
:
Literal
[
None
]
=
None
,
parser
:
Literal
[
None
]
=
None
,
max_response_size
:
Optional
[
int
]
=
None
,
)
->
Union
[
JsonDict
,
list
]:
)
->
Union
[
JsonDict
,
list
]:
...
...
...
@@ -752,6 +759,7 @@ class MatrixFederationHttpClient:
...
@@ -752,6 +759,7 @@ class MatrixFederationHttpClient:
backoff_on_404
:
bool
=
False
,
backoff_on_404
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
parser
:
Optional
[
ByteParser
[
T
]]
=
None
,
parser
:
Optional
[
ByteParser
[
T
]]
=
None
,
max_response_size
:
Optional
[
int
]
=
None
,
)
->
T
:
)
->
T
:
...
...
...
@@ -768,6 +776,7 @@ class MatrixFederationHttpClient:
...
@@ -768,6 +776,7 @@ class MatrixFederationHttpClient:
backoff_on_404
:
bool
=
False
,
backoff_on_404
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
try_trailing_slash_on_400
:
bool
=
False
,
parser
:
Optional
[
ByteParser
]
=
None
,
parser
:
Optional
[
ByteParser
]
=
None
,
max_response_size
:
Optional
[
int
]
=
None
,
):
):
"""
Sends the specified json data using PUT
"""
Sends the specified json data using PUT
...
@@ -803,6 +812,8 @@ class MatrixFederationHttpClient:
...
@@ -803,6 +812,8 @@ class MatrixFederationHttpClient:
enabled.
enabled.
parser: The parser to use to decode the response. Defaults to
parser: The parser to use to decode the response. Defaults to
parsing as JSON.
parsing as JSON.
max_response_size: The maximum size to read from the response, if None
uses the default.
Returns:
Returns:
Succeeds when we get a 2xx HTTP response. The
Succeeds when we get a 2xx HTTP response. The
...
@@ -853,6 +864,7 @@ class MatrixFederationHttpClient:
...
@@ -853,6 +864,7 @@ class MatrixFederationHttpClient:
response
,
response
,
start_ms
,
start_ms
,
parser
=
parser
,
parser
=
parser
,
max_response_size
=
max_response_size
,
)
)
return
body
return
body
...
...
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