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/11/28 21:15:22 UTC

[httpcomponents-client] branch 4.5.x updated: HTTPCLIENT-2121: Tolerate premature end of Content-Length delimited message body in case of a redirect

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

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


The following commit(s) were added to refs/heads/4.5.x by this push:
     new 33043db  HTTPCLIENT-2121: Tolerate premature end of Content-Length delimited message body in case of a redirect
33043db is described below

commit 33043db1a9f8632220edc9ff5eeed22b762b84e0
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Oct 19 18:46:27 2020 +0200

    HTTPCLIENT-2121: Tolerate premature end of Content-Length delimited message body in case of a redirect
---
 .../main/java/org/apache/http/impl/execchain/RedirectExec.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
index 3a5673d..ea339d1 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
@@ -33,6 +33,7 @@ import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.ConnectionClosedException;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
@@ -160,8 +161,13 @@ public class RedirectExec implements ClientExecChain {
                     if (this.log.isDebugEnabled()) {
                         this.log.debug("Redirecting to '" + uri + "' via " + currentRoute);
                     }
-                    EntityUtils.consume(response.getEntity());
-                    response.close();
+                    try {
+                        EntityUtils.consume(response.getEntity());
+                    } catch (final ConnectionClosedException ex) {
+                        this.log.debug(ex.getMessage());
+                    } finally {
+                        response.close();
+                    }
                 } else {
                     return response;
                 }