0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-25 01:14:14 +01:00
synapse/tests/http
Richard van der Hoff 1c262431f9
Fix handling of connection timeouts in outgoing http requests (#8400)
* Remove `on_timeout_cancel` from `timeout_deferred`

The `on_timeout_cancel` param to `timeout_deferred` wasn't always called on a
timeout (in particular if the canceller raised an exception), so it was
unreliable. It was also only used in one place, and to be honest it's easier to
do what it does a different way.

* Fix handling of connection timeouts in outgoing http requests

Turns out that if we get a timeout during connection, then a different
exception is raised, which wasn't always handled correctly.

To fix it, catch the exception in SimpleHttpClient and turn it into a
RequestTimedOutError (which is already a documented exception).

Also add a description to RequestTimedOutError so that we can see which stage
it failed at.

* Fix incorrect handling of timeouts reading federation responses

This was trapping the wrong sort of TimeoutError, so was never being hit.

The effect was relatively minor, but we should fix this so that it does the
expected thing.

* Fix inconsistent handling of `timeout` param between methods

`get_json`, `put_json` and `delete_json` were applying a different timeout to
the response body to `post_json`; bring them in line and test.

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Co-authored-by: Erik Johnston <erik@matrix.org>
2020-09-29 10:29:21 +01:00
..
federation Stop sub-classing object (#8249) 2020-09-04 06:54:56 -04:00
__init__.py Use TLSv1.2 for fake servers in tests (#8208) 2020-09-10 19:49:08 +01:00
ca.crt
ca.key
server.key
test_additional_resource.py Merge different Resource implementation classes (#7732) 2020-07-03 19:02:19 +01:00
test_endpoint.py
test_fedclient.py Fix handling of connection timeouts in outgoing http requests (#8400) 2020-09-29 10:29:21 +01:00
test_proxyagent.py Support for routing outbound HTTP requests via a proxy (#6239) 2019-11-01 14:07:44 +00:00
test_servlet.py Fix the exception that is raised when invalid JSON is encountered. (#8291) 2020-09-10 14:55:25 -04:00
test_simple_client.py Fix handling of connection timeouts in outgoing http requests (#8400) 2020-09-29 10:29:21 +01:00