Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
14f581ab
Commit
14f581ab
authored
7 years ago
by
Richard van der Hoff
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2584 from matrix-org/rav/fix_httpclient_logcontexts
Fix logcontext leaks in httpclient
parents
2fd9831f
0d8e3ad4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/http/client.py
+9
-10
9 additions, 10 deletions
synapse/http/client.py
with
9 additions
and
10 deletions
synapse/http/client.py
+
9
−
10
View file @
14f581ab
...
...
@@ -18,7 +18,7 @@ from OpenSSL.SSL import VERIFY_NONE
from
synapse.api.errors
import
(
CodeMessageException
,
MatrixCodeMessageException
,
SynapseError
,
Codes
,
)
from
synapse.util.logcontext
import
preserve_context_over_fn
from
synapse.util.logcontext
import
make_deferred_yieldable
from
synapse.util
import
logcontext
import
synapse.metrics
from
synapse.http.endpoint
import
SpiderEndpoint
...
...
@@ -130,7 +130,7 @@ class SimpleHttpClient(object):
bodyProducer
=
FileBodyProducer
(
StringIO
(
query_bytes
))
)
body
=
yield
preserve_context_over_fn
(
readBody
,
response
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
)
)
defer
.
returnValue
(
json
.
loads
(
body
))
...
...
@@ -150,7 +150,7 @@ class SimpleHttpClient(object):
bodyProducer
=
FileBodyProducer
(
StringIO
(
json_str
))
)
body
=
yield
preserve_context_over_fn
(
readBody
,
response
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
)
)
if
200
<=
response
.
code
<
300
:
defer
.
returnValue
(
json
.
loads
(
body
))
...
...
@@ -215,7 +215,7 @@ class SimpleHttpClient(object):
bodyProducer
=
FileBodyProducer
(
StringIO
(
json_str
))
)
body
=
yield
preserve_context_over_fn
(
readBody
,
response
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
)
)
if
200
<=
response
.
code
<
300
:
defer
.
returnValue
(
json
.
loads
(
body
))
...
...
@@ -254,7 +254,7 @@ class SimpleHttpClient(object):
})
)
body
=
yield
preserve_context_over_fn
(
readBody
,
response
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
)
)
if
200
<=
response
.
code
<
300
:
defer
.
returnValue
(
body
)
...
...
@@ -315,10 +315,9 @@ class SimpleHttpClient(object):
# straight back in again
try
:
length
=
yield
preserve_context_over_fn
(
_readBodyToFile
,
response
,
output_stream
,
max_size
)
length
=
yield
make_deferred_yieldable
(
_readBodyToFile
(
response
,
output_stream
,
max_size
,
))
except
Exception
as
e
:
logger
.
exception
(
"
Failed to download body
"
)
raise
SynapseError
(
...
...
@@ -395,7 +394,7 @@ class CaptchaServerHttpClient(SimpleHttpClient):
)
try
:
body
=
yield
preserve_context_over_fn
(
readBody
,
response
)
body
=
yield
make_deferred_yieldable
(
readBody
(
response
)
)
defer
.
returnValue
(
body
)
except
PartialDownloadError
as
e
:
# twisted dislikes google's response, no content length.
...
...
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