[cxf] branch master updated: CXF-7959: WebClient invocation builder header(name, value) method is not implemented according to interface specification

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[cxf] branch master updated: CXF-7959: WebClient invocation builder header(name, value) method is not implemented according to interface specification

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

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new a2296f2  CXF-7959: WebClient invocation builder header(name, value) method is not implemented according to interface specification
a2296f2 is described below

commit a2296f2e54dff0b353581d2e6fb0d72fbc8368a3
Author: reta <[hidden email]>
AuthorDate: Sat Feb 8 15:36:18 2020 -0500

    CXF-7959: WebClient invocation builder header(name, value) method is not implemented according to interface specification
---
 .../org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java  | 8 +++++++-
 .../apache/cxf/jaxrs/client/spec/InvocationBuilderImplTest.java  | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
index 3e623ef..471a9ec 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImpl.java
@@ -270,7 +270,13 @@ public class InvocationBuilderImpl implements Invocation.Builder {
         if (hd != null) {
             value = hd.toString(value);
         }
-        webClient.header(name, value);
+        
+        // If value is null then all current headers of the same name should be removed
+        if (value == null) {
+            webClient.replaceHeader(name, value);
+        } else {
+            webClient.header(name, value);
+        }
     }
 
     @Override
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImplTest.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImplTest.java
index 9d81127..4bd6dc4 100644
--- a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImplTest.java
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/spec/InvocationBuilderImplTest.java
@@ -68,6 +68,15 @@ public class InvocationBuilderImplTest {
         String sentHeaders = response.readEntity(String.class);
         assertTrue(sentHeaders.contains("Header1=b"));
         assertFalse(sentHeaders.contains("UnexpectedHeader"));
+
+        // If value is null then all current headers of the same name
+        // should be removed.
+        builder.header("Header1", null);
+        builder.header("Header2", "b");
+        response = builder.get();
+        sentHeaders = response.readEntity(String.class);
+        assertTrue(sentHeaders.contains("Header2=b"));
+        assertFalse(sentHeaders.contains("Header1"));
         
         // null headers map should clear all headers
         builder.headers(null);