You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/04/08 08:32:23 UTC

[httpcomponents-client] branch master updated: HTTPCLIENT-2075: new method Request.responseTimeout(Timeout) in Fluent HC

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 272f002  HTTPCLIENT-2075: new method Request.responseTimeout(Timeout) in Fluent HC
272f002 is described below

commit 272f00297ee6c77228101fe8dfb35f44ba72af25
Author: Ralph <ra...@rwth-aachen.de>
AuthorDate: Tue Apr 7 23:52:06 2020 +0200

    HTTPCLIENT-2075: new method Request.responseTimeout(Timeout) in Fluent HC
---
 .../src/main/java/org/apache/hc/client5/http/fluent/Request.java | 9 +++++++++
 .../apache/hc/client5/http/examples/fluent/FluentRequests.java   | 1 +
 2 files changed, 10 insertions(+)

diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
index 955eea6..b24927d 100644
--- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
+++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
@@ -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) {
diff --git a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
index ceed7c8..94834fd 100644
--- a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
@@ -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,