Add connection timeout for forked ratpack http client (#3239)

This commit is contained in:
Lauri Tulmin 2021-06-10 18:44:36 +03:00 committed by GitHub
parent e93ff4d419
commit 52b23d116e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@
package client
import java.time.Duration
import ratpack.exec.Promise
import ratpack.http.client.HttpClient
@ -13,6 +14,8 @@ class RatpackForkedHttpClientTest extends RatpackHttpClientTest {
@Override
Promise<Integer> internalSendRequest(HttpClient client, String method, URI uri, Map<String, String> headers) {
def resp = client.request(uri) { spec ->
// Connect timeout for the whole client was added in 1.5 so we need to add timeout for each request
spec.connectTimeout(Duration.ofSeconds(2))
spec.method(method)
spec.headers { headersSpec ->
headers.entrySet().each {

View File

@ -46,7 +46,6 @@ class RatpackHttpClientTest extends HttpClientTest<Void> implements AgentTestTra
HttpClient buildHttpClient(Action<? super HttpClientSpec> action) {
HttpClient.of {
it.readTimeout(Duration.ofSeconds(2))
// Connect timeout added in 1.5
// execController method added in 1.9
if (HttpClientSpec.metaClass.getMetaMethod("execController") != null) {
it.execController(exec.getController())
@ -81,6 +80,7 @@ class RatpackHttpClientTest extends HttpClientTest<Void> implements AgentTestTra
// overridden in RatpackForkedHttpClientTest
Promise<Integer> internalSendRequest(HttpClient client, String method, URI uri, Map<String, String> headers) {
def resp = client.request(uri) { spec ->
// Connect timeout for the whole client was added in 1.5 so we need to add timeout for each request
spec.connectTimeout(Duration.ofSeconds(2))
spec.method(method)
spec.headers { headersSpec ->