HTTPCLIENT-2075: new method Request.responseTimeout(Timeout) in Fluent HC
This commit is contained in:
parent
a93d5c0c1d
commit
272f00297e
|
@ -77,6 +77,7 @@ public class Request {
|
|||
private final ClassicHttpRequest request;
|
||||
private Boolean useExpectContinue;
|
||||
private Timeout connectTimeout;
|
||||
private Timeout responseTimeout;
|
||||
private HttpHost proxy;
|
||||
|
||||
private SimpleDateFormat dateFormatter;
|
||||
|
@ -177,6 +178,9 @@ public class Request {
|
|||
if (this.connectTimeout != null) {
|
||||
builder.setConnectTimeout(this.connectTimeout);
|
||||
}
|
||||
if (this.responseTimeout != null) {
|
||||
builder.setResponseTimeout(this.responseTimeout);
|
||||
}
|
||||
if (this.proxy != null) {
|
||||
builder.setProxy(this.proxy);
|
||||
}
|
||||
|
@ -292,6 +296,11 @@ public class Request {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Request responseTimeout(final Timeout timeout) {
|
||||
this.responseTimeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
//// HTTP connection route operations
|
||||
|
||||
public Request viaProxy(final HttpHost proxy) {
|
||||
|
|
|
@ -44,6 +44,7 @@ public class FluentRequests {
|
|||
// Execute a GET with timeout settings and return response content as String.
|
||||
Request.get("http://somehost/")
|
||||
.connectTimeout(Timeout.ofSeconds(1))
|
||||
.responseTimeout(Timeout.ofSeconds(5))
|
||||
.execute().returnContent().asString();
|
||||
|
||||
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
|
||||
|
|
Loading…
Reference in New Issue