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
7c0295f1
Commit
7c0295f1
authored
6 years ago
by
Andrew Morgan
Browse files
Options
Downloads
Patches
Plain Diff
no kwargs today
parent
66cdb840
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/http/matrixfederationclient.py
+12
-7
12 additions, 7 deletions
synapse/http/matrixfederationclient.py
with
12 additions
and
7 deletions
synapse/http/matrixfederationclient.py
+
12
−
7
View file @
7c0295f1
...
@@ -193,7 +193,9 @@ class MatrixFederationHttpClient(object):
...
@@ -193,7 +193,9 @@ class MatrixFederationHttpClient(object):
self
,
self
,
request
,
request
,
try_trailing_slash_on_400
=
False
,
try_trailing_slash_on_400
=
False
,
**
kwargs
):
backoff_on_404
=
False
,
send_request_args
=
{},
):
"""
Wrapper for _send_request which can optionally retry the request
"""
Wrapper for _send_request which can optionally retry the request
upon receiving a combination of a 400 HTTP response code and a
upon receiving a combination of a 400 HTTP response code and a
'
M_UNRECOGNIZED
'
errcode. This is a workaround for Synapse <=v0.99.2
'
M_UNRECOGNIZED
'
errcode. This is a workaround for Synapse <=v0.99.2
...
@@ -204,14 +206,17 @@ class MatrixFederationHttpClient(object):
...
@@ -204,14 +206,17 @@ class MatrixFederationHttpClient(object):
try_trailing_slash_on_400 (bool): Whether on receiving a 400
try_trailing_slash_on_400 (bool): Whether on receiving a 400
'
M_UNRECOGNIZED
'
from the server to retry the request with a
'
M_UNRECOGNIZED
'
from the server to retry the request with a
trailing slash appended to the request path.
trailing slash appended to the request path.
kwargs (Dict): A dictionary of arguments to pass to
404_backoff (bool): Whether to backoff on 404 when making a
request with a trailing slash (only affects request if
try_trailing_slash_on_400 is True).
send_request_args (Dict): A dictionary of arguments to pass to
`_send_request()`.
`_send_request()`.
Returns:
Returns:
Deferred[twisted.web.client.Response]: resolves with the HTTP
Deferred[twisted.web.client.Response]: resolves with the HTTP
response object on success.
response object on success.
"""
"""
response
=
yield
self
.
_send_request
(
**
kw
args
)
response
=
yield
self
.
_send_request
(
**
send_request_
args
)
if
not
try_trailing_slash_on_400
:
if
not
try_trailing_slash_on_400
:
defer
.
returnValue
(
response
)
defer
.
returnValue
(
response
)
...
@@ -226,10 +231,10 @@ class MatrixFederationHttpClient(object):
...
@@ -226,10 +231,10 @@ class MatrixFederationHttpClient(object):
# trailing slash on Synapse <=v0.99.2.
# trailing slash on Synapse <=v0.99.2.
if
(
response
.
code
==
400
and
body
.
get
(
"
errcode
"
)
==
"
M_UNRECOGNIZED
"
):
if
(
response
.
code
==
400
and
body
.
get
(
"
errcode
"
)
==
"
M_UNRECOGNIZED
"
):
# Enable backoff if initially disabled
# Enable backoff if initially disabled
kw
args
[
"
backoff_on_404
"
]
=
backoff_on_404
send_request_
args
[
"
backoff_on_404
"
]
=
backoff_on_404
kw
args
[
"
path
"
]
+=
"
/
"
send_request_
args
[
"
path
"
]
+=
"
/
"
response
=
yield
self
.
_send_request
(
**
kw
args
)
response
=
yield
self
.
_send_request
(
**
send_request_
args
)
defer
.
returnValue
(
response
)
defer
.
returnValue
(
response
)
...
@@ -581,7 +586,7 @@ class MatrixFederationHttpClient(object):
...
@@ -581,7 +586,7 @@ class MatrixFederationHttpClient(object):
}
}
response
=
yield
self
.
_send_request_with_optional_trailing_slash
(
response
=
yield
self
.
_send_request_with_optional_trailing_slash
(
request
,
try_trailing_slash_on_400
,
**
send_request_args
)
request
,
try_trailing_slash_on_400
,
backoff_on_404
,
send_request_args
)
body
=
yield
_handle_json_response
(
body
=
yield
_handle_json_response
(
self
.
hs
.
get_reactor
(),
self
.
default_timeout
,
request
,
response
,
self
.
hs
.
get_reactor
(),
self
.
default_timeout
,
request
,
response
,
...
...
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