fix(client): HttpTransport sets request timeout (no more infinite hang)
This commit is contained in:
@@ -14,6 +14,10 @@ var _http: HTTPRequest
|
||||
|
||||
func _init(http: HTTPRequest) -> void:
|
||||
_http = http
|
||||
# Bound a hung proxy so the request completes with RESULT_TIMEOUT (→ failed()
|
||||
# → the service degrades) instead of never returning. Without this the
|
||||
# considering-state indicator would rotate forever on a hang.
|
||||
_http.timeout = ProxyConfig.request_timeout_seconds()
|
||||
|
||||
|
||||
func post_json(path: String, body: Dictionary) -> DmResponse:
|
||||
|
||||
@@ -78,3 +78,13 @@ func test_request_timeout_override_and_reject_nonpositive():
|
||||
ProjectSettings.set_setting(ProxyConfig.TIMEOUT_SETTING, 0.0)
|
||||
assert_eq(ProxyConfig.request_timeout_seconds(), ProxyConfig.TIMEOUT_DEFAULT)
|
||||
ProjectSettings.clear(ProxyConfig.TIMEOUT_SETTING)
|
||||
|
||||
|
||||
func test_http_transport_sets_request_timeout():
|
||||
var HttpTransport = preload("res://scripts/net/http_transport.gd")
|
||||
var ProxyConfig = preload("res://scripts/net/proxy_config.gd")
|
||||
var http := HTTPRequest.new()
|
||||
autofree(http)
|
||||
HttpTransport.new(http)
|
||||
assert_eq(http.timeout, ProxyConfig.request_timeout_seconds())
|
||||
assert_gt(http.timeout, 0.0) # the whole point — no longer disabled
|
||||
|
||||
Reference in New Issue
Block a user