You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2010/10/05 19:28:27 UTC
svn commit: r1004728 - in /cxf/branches/2.2.x-fixes: ./
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Author: sergeyb
Date: Tue Oct 5 17:28:26 2010
New Revision: 1004728
URL: http://svn.apache.org/viewvc?rev=1004728&view=rev
Log:
Merged revisions 1004723 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1004723 | sergeyb | 2010-10-05 18:23:23 +0100 (Tue, 05 Oct 2010) | 1 line
[CXF-3024] Fixing ResponseBuilder.location to check for query and fragment
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
svn:mergeinfo = /cxf/trunk:1004723
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java?rev=1004728&r1=1004727&r2=1004728&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java Tue Oct 5 17:28:26 2010
@@ -93,15 +93,19 @@ public final class ResponseBuilderImpl e
return setHeader(HttpHeaders.CONTENT_LANGUAGE, language);
}
- public ResponseBuilder location(URI location) {
- if (!location.isAbsolute()) {
+ public ResponseBuilder location(URI loc) {
+ if (!loc.isAbsolute()) {
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage != null) {
+
UriInfo ui = new UriInfoImpl(currentMessage.getExchange().getInMessage(), null);
- location = ui.getBaseUriBuilder().path(location.toString()).build();
+ loc = ui.getBaseUriBuilder()
+ .path(loc.getRawPath())
+ .replaceQuery(loc.getRawQuery())
+ .fragment(loc.getRawFragment()).buildFromEncoded();
}
}
- return setHeader(HttpHeaders.LOCATION, location);
+ return setHeader(HttpHeaders.LOCATION, loc);
}
public ResponseBuilder contentLocation(URI location) {
Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1004728&r1=1004727&r2=1004728&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Tue Oct 5 17:28:26 2010
@@ -23,6 +23,7 @@ package org.apache.cxf.systest.jaxrs;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.URI;
import java.net.URL;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -58,6 +59,7 @@ import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.StreamingOutput;
+import javax.ws.rs.core.UriBuilder;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -113,6 +115,14 @@ public class BookStore {
}
@GET
+ @Path("tempredirect")
+ public Response tempRedirect() {
+ URI uri = UriBuilder.fromPath("whatever/redirection")
+ .queryParam("css1", "http://bar").build();
+ return Response.temporaryRedirect(uri).build();
+ }
+
+ @GET
@Path("propogateexception")
public Book propogateException() throws BookNotFoundFault {
throw new BookNotFoundFault("Book Exception");
Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1004728&r1=1004727&r2=1004728&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Tue Oct 5 17:28:26 2010
@@ -28,6 +28,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.Header;
@@ -69,6 +70,17 @@ public class JAXRSClientServerBookTest e
}
@Test
+ public void testTempRedirectWebClient() throws Exception {
+ WebClient client = WebClient.create("http://localhost:" + PORT + "/bookstore/tempredirect");
+ Response r = client.type("*/*").get();
+ assertEquals(307, r.getStatus());
+ MultivaluedMap<String, Object> map = r.getMetadata();
+ assertEquals("http://localhost:" + PORT + "/whatever/redirection?css1=http%3A//bar",
+ map.getFirst("Location").toString());
+ }
+
+
+ @Test
public void testOnewayProxy() throws Exception {
BookStore proxy = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
proxy.onewayRequest();