hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1695155 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
Date Mon, 10 Aug 2015 19:43:54 GMT
Author: olegk
Date: Mon Aug 10 19:43:53 2015
New Revision: 1695155

URL: http://svn.apache.org/r1695155
Log:
HTTPCLIENT-1671: default headers should only be set if a header with the same name hasn't
already been set

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java?rev=1695155&r1=1695154&r2=1695155&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
Mon Aug 10 19:43:53 2015
@@ -72,7 +72,9 @@ public class RequestDefaultHeaders imple
 
         if (this.defaultHeaders != null) {
             for (final Header defHeader : this.defaultHeaders) {
-                request.addHeader(defHeader);
+                if(!request.containsHeader(defHeader.getName())) {
+                    request.addHeader(defHeader);
+                }
             }
         }
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java?rev=1695155&r1=1695154&r2=1695155&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestDefaultHeaders.java
Mon Aug 10 19:43:53 2015
@@ -66,16 +66,15 @@ public class TestRequestDefaultHeaders {
         final HttpRequest request = new BasicHttpRequest("GET", "/");
         request.addHeader("custom", "stuff");
         final List<Header> defheaders = new ArrayList<>();
-        defheaders.add(new BasicHeader("custom", "more stuff"));
+        defheaders.add(new BasicHeader("custom", "other stuff"));
         final HttpContext context = new BasicHttpContext();
 
         final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(defheaders);
         interceptor.process(request, context);
         final Header[] headers = request.getHeaders("custom");
         Assert.assertNotNull(headers);
-        Assert.assertEquals(2, headers.length);
+        Assert.assertEquals(1, headers.length);
         Assert.assertEquals("stuff", headers[0].getValue());
-        Assert.assertEquals("more stuff", headers[1].getValue());
     }
 
 }



Mime
View raw message