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
a53e0160
Unverified
Commit
a53e0160
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Ensure the msg property of HttpResponseException is a string. (#7979)
parent
d90087cf
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/7979.misc
+1
-0
1 addition, 0 deletions
changelog.d/7979.misc
synapse/http/client.py
+12
-4
12 additions, 4 deletions
synapse/http/client.py
synapse/http/matrixfederationclient.py
+4
-3
4 additions, 3 deletions
synapse/http/matrixfederationclient.py
with
17 additions
and
7 deletions
changelog.d/7979.misc
0 → 100644
+
1
−
0
View file @
a53e0160
Switch to the JSON implementation from the standard library and bump the minimum version of the canonicaljson library to 1.2.0.
This diff is collapsed.
Click to expand it.
synapse/http/client.py
+
12
−
4
View file @
a53e0160
...
@@ -395,7 +395,9 @@ class SimpleHttpClient(object):
...
@@ -395,7 +395,9 @@ class SimpleHttpClient(object):
if
200
<=
response
.
code
<
300
:
if
200
<=
response
.
code
<
300
:
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
else
:
else
:
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
,
body
)
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
),
body
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
post_json_get_json
(
self
,
uri
,
post_json
,
headers
=
None
):
def
post_json_get_json
(
self
,
uri
,
post_json
,
headers
=
None
):
...
@@ -436,7 +438,9 @@ class SimpleHttpClient(object):
...
@@ -436,7 +438,9 @@ class SimpleHttpClient(object):
if
200
<=
response
.
code
<
300
:
if
200
<=
response
.
code
<
300
:
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
else
:
else
:
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
,
body
)
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
),
body
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_json
(
self
,
uri
,
args
=
{},
headers
=
None
):
def
get_json
(
self
,
uri
,
args
=
{},
headers
=
None
):
...
@@ -509,7 +513,9 @@ class SimpleHttpClient(object):
...
@@ -509,7 +513,9 @@ class SimpleHttpClient(object):
if
200
<=
response
.
code
<
300
:
if
200
<=
response
.
code
<
300
:
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
return
json
.
loads
(
body
.
decode
(
"
utf-8
"
))
else
:
else
:
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
,
body
)
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
),
body
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
get_raw
(
self
,
uri
,
args
=
{},
headers
=
None
):
def
get_raw
(
self
,
uri
,
args
=
{},
headers
=
None
):
...
@@ -544,7 +550,9 @@ class SimpleHttpClient(object):
...
@@ -544,7 +550,9 @@ class SimpleHttpClient(object):
if
200
<=
response
.
code
<
300
:
if
200
<=
response
.
code
<
300
:
return
body
return
body
else
:
else
:
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
,
body
)
raise
HttpResponseException
(
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
),
body
)
# XXX: FIXME: This is horribly copy-pasted from matrixfederationclient.
# XXX: FIXME: This is horribly copy-pasted from matrixfederationclient.
# The two should be factored out.
# The two should be factored out.
...
...
This diff is collapsed.
Click to expand it.
synapse/http/matrixfederationclient.py
+
4
−
3
View file @
a53e0160
...
@@ -447,6 +447,7 @@ class MatrixFederationHttpClient(object):
...
@@ -447,6 +447,7 @@ class MatrixFederationHttpClient(object):
).
inc
()
).
inc
()
set_tag
(
tags
.
HTTP_STATUS_CODE
,
response
.
code
)
set_tag
(
tags
.
HTTP_STATUS_CODE
,
response
.
code
)
response_phrase
=
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
)
if
200
<=
response
.
code
<
300
:
if
200
<=
response
.
code
<
300
:
logger
.
debug
(
logger
.
debug
(
...
@@ -454,7 +455,7 @@ class MatrixFederationHttpClient(object):
...
@@ -454,7 +455,7 @@ class MatrixFederationHttpClient(object):
request
.
txn_id
,
request
.
txn_id
,
request
.
destination
,
request
.
destination
,
response
.
code
,
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
)
,
response
_
phrase
,
)
)
pass
pass
else
:
else
:
...
@@ -463,7 +464,7 @@ class MatrixFederationHttpClient(object):
...
@@ -463,7 +464,7 @@ class MatrixFederationHttpClient(object):
request
.
txn_id
,
request
.
txn_id
,
request
.
destination
,
request
.
destination
,
response
.
code
,
response
.
code
,
response
.
phrase
.
decode
(
"
ascii
"
,
errors
=
"
replace
"
)
,
response
_
phrase
,
)
)
# :'(
# :'(
# Update transactions table?
# Update transactions table?
...
@@ -487,7 +488,7 @@ class MatrixFederationHttpClient(object):
...
@@ -487,7 +488,7 @@ class MatrixFederationHttpClient(object):
)
)
body
=
None
body
=
None
e
=
HttpResponseException
(
response
.
code
,
response
.
phrase
,
body
)
e
=
HttpResponseException
(
response
.
code
,
response
_
phrase
,
body
)
# Retry if the error is a 429 (Too Many Requests),
# Retry if the error is a 429 (Too Many Requests),
# otherwise just raise a standard HttpResponseException
# otherwise just raise a standard HttpResponseException
...
...
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