cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1171662 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Date Fri, 16 Sep 2011 16:55:49 GMT
Author: dkulp
Date: Fri Sep 16 16:55:48 2011
New Revision: 1171662

URL: http://svn.apache.org/viewvc?rev=1171662&view=rev
Log:
Merged revisions 1171291 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1171291 | sergeyb | 2011-09-15 18:09:13 -0400 (Thu, 15 Sep 2011) | 1 line
  
  [CXF-3806] Adding replaceHeader method to WebClient
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1171662&r1=1171661&r2=1171662&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Fri Sep 16 16:55:48 2011
@@ -565,6 +565,21 @@ public class WebClient extends AbstractC
     }
     
     /**
+     * Replaces the header value with the new values.
+     * @param headerName headerValues
+     * @param value new values, null is equivalent to removing the header
+     * @return updated WebClient
+     */
+    public WebClient replaceHeader(String headerName, String value) {
+        MultivaluedMap<String, String> headers = getState().getRequestHeaders();
+        headers.remove(headerName);
+        if (value != null) {
+            headers.add(headerName, value);
+        }
+        return this;
+    }
+    
+    /**
      * Replaces the current query with the new value.
      * @param queryString the new value, providing a null is
      *        equivalent to calling resetQuery().  

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=1171662&r1=1171661&r2=1171662&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Fri Sep 16 16:55:48 2011
@@ -31,6 +31,25 @@ import org.junit.Test;
 public class WebClientTest extends Assert {
 
     @Test
+    public void testReplaceHeader() {
+        WebClient wc = WebClient.create("http://foo").header("a", "b");
+        assertEquals(1, wc.getHeaders().size());
+        assertEquals("b", wc.getHeaders().getFirst("a"));
+        wc.replaceHeader("a", "c");
+        assertEquals(1, wc.getHeaders().size());
+        assertEquals("c", wc.getHeaders().getFirst("a"));
+    }
+    
+    @Test
+    public void testRemoveHeader() {
+        WebClient wc = WebClient.create("http://foo").header("a", "b");
+        assertEquals(1, wc.getHeaders().size());
+        assertEquals("b", wc.getHeaders().getFirst("a"));
+        wc.replaceHeader("a", null);
+        assertEquals(0, wc.getHeaders().size());
+    }
+    
+    @Test
     public void testEncoding() {
         URI u = WebClient.create("http://foo").path("bar+ %2B").matrix("a", "value+ ")
             .query("b", "bv+ %2B").getCurrentURI();



Mime
View raw message