mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-28 07:00:51 +03:00
Fix logcontext leaks in httpclient
`preserve_context_over_fn` is borked
This commit is contained in:
parent
1dd0f53b21
commit
0d8e3ad48b
1 changed files with 9 additions and 10 deletions
|
@ -18,7 +18,7 @@ from OpenSSL.SSL import VERIFY_NONE
|
||||||
from synapse.api.errors import (
|
from synapse.api.errors import (
|
||||||
CodeMessageException, MatrixCodeMessageException, SynapseError, Codes,
|
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
|
from synapse.util import logcontext
|
||||||
import synapse.metrics
|
import synapse.metrics
|
||||||
from synapse.http.endpoint import SpiderEndpoint
|
from synapse.http.endpoint import SpiderEndpoint
|
||||||
|
@ -130,7 +130,7 @@ class SimpleHttpClient(object):
|
||||||
bodyProducer=FileBodyProducer(StringIO(query_bytes))
|
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))
|
defer.returnValue(json.loads(body))
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class SimpleHttpClient(object):
|
||||||
bodyProducer=FileBodyProducer(StringIO(json_str))
|
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:
|
if 200 <= response.code < 300:
|
||||||
defer.returnValue(json.loads(body))
|
defer.returnValue(json.loads(body))
|
||||||
|
@ -215,7 +215,7 @@ class SimpleHttpClient(object):
|
||||||
bodyProducer=FileBodyProducer(StringIO(json_str))
|
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:
|
if 200 <= response.code < 300:
|
||||||
defer.returnValue(json.loads(body))
|
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:
|
if 200 <= response.code < 300:
|
||||||
defer.returnValue(body)
|
defer.returnValue(body)
|
||||||
|
@ -315,10 +315,9 @@ class SimpleHttpClient(object):
|
||||||
# straight back in again
|
# straight back in again
|
||||||
|
|
||||||
try:
|
try:
|
||||||
length = yield preserve_context_over_fn(
|
length = yield make_deferred_yieldable(_readBodyToFile(
|
||||||
_readBodyToFile,
|
response, output_stream, max_size,
|
||||||
response, output_stream, max_size
|
))
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Failed to download body")
|
logger.exception("Failed to download body")
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
|
@ -395,7 +394,7 @@ class CaptchaServerHttpClient(SimpleHttpClient):
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = yield preserve_context_over_fn(readBody, response)
|
body = yield make_deferred_yieldable(readBody(response))
|
||||||
defer.returnValue(body)
|
defer.returnValue(body)
|
||||||
except PartialDownloadError as e:
|
except PartialDownloadError as e:
|
||||||
# twisted dislikes google's response, no content length.
|
# twisted dislikes google's response, no content length.
|
||||||
|
|
Loading…
Reference in a new issue