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 2015/12/06 18:36:32 UTC
cxf git commit: [CXF-6679] Trying to cache HTTPServletRequest
parameters if requested by a user
Repository: cxf
Updated Branches:
refs/heads/master 0336a2399 -> 310847cee
[CXF-6679] Trying to cache HTTPServletRequest parameters if requested by a user
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/310847ce
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/310847ce
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/310847ce
Branch: refs/heads/master
Commit: 310847ceecdaedfe62f7383e9af01702b297b034
Parents: 0336a23
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Sun Dec 6 17:36:08 2015 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Sun Dec 6 17:36:08 2015 +0000
----------------------------------------------------------------------
.../cxf/transport/http/AbstractHTTPDestination.java | 6 ++++++
.../org/apache/cxf/systest/jaxrs/BookStoreSpring.java | 10 ++++++++++
.../systest/jaxrs/JAXRSClientServerSpringBookTest.java | 12 ++++++++++++
.../jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml | 7 +++++++
4 files changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/310847ce/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
index 7a4e5c6..0861e6e 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
@@ -44,6 +44,7 @@ import org.apache.cxf.attachment.AttachmentDataSource;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.Base64Exception;
import org.apache.cxf.common.util.Base64Utility;
+import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.Configurable;
import org.apache.cxf.configuration.security.AuthorizationPolicy;
@@ -105,6 +106,7 @@ public abstract class AbstractHTTPDestination
private static final String SSL_PEER_CERT_CHAIN_ATTRIBUTE = "javax.servlet.request.X509Certificate";
private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
+ private static final String CACHE_HTTP_REQUEST_PARAMETERS = "cache.http.request.parameters";
protected final Bus bus;
protected DestinationRegistry registry;
@@ -295,6 +297,10 @@ public abstract class AbstractHTTPDestination
resp);
final Exchange exchange = inMessage.getExchange();
+ if (bus != null && PropertyUtils.isTrue(
+ bus.getProperty(CACHE_HTTP_REQUEST_PARAMETERS))) {
+ req.getParameterNames();
+ }
DelegatingInputStream in = new DelegatingInputStream(req.getInputStream()) {
public void cacheInput() {
if (!cached && (exchange.isOneWay() || isWSAddressingReplyToSpecified(exchange))) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/310847ce/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
index ab08c96..8ae6bff 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
@@ -82,6 +82,16 @@ public class BookStoreSpring {
//System.out.println("PreDestroy called");
}
+ @POST
+ @Path("/bookform")
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces("application/xml")
+ public Book echoBookForm(@Context HttpServletRequest req) {
+ String name = req.getParameter("name");
+ long id = Long.valueOf(req.getParameter("id"));
+ return new Book(name, id);
+ }
+
@GET
@Path("/books/webex")
public Books getBookWebEx() {
http://git-wip-us.apache.org/repos/asf/cxf/blob/310847ce/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index 7a1d546..6ae9f4e 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -97,6 +97,18 @@ public class JAXRSClientServerSpringBookTest extends AbstractBusClientServerTest
}
@Test
+ public void testEchoBookForm() throws Exception {
+ String address = "http://localhost:" + PORT + "/bus/thebooksform/bookform";
+ WebClient wc = WebClient.create(address);
+ WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+ Book b =
+ wc.form(new Form().param("name", "CXFForm").param("id", "125"))
+ .readEntity(Book.class);
+ assertEquals("CXFForm", b.getName());
+ assertEquals(125L, b.getId());
+ }
+
+ @Test
public void testGetBookWebEx4() throws Exception {
final String address = "http://localhost:" + PORT + "/the/thebooks%203/bookstore/books/webex2";
doTestGetBookWebEx(address);
http://git-wip-us.apache.org/repos/asf/cxf/blob/310847ce/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
index ce855da..f259744 100644
--- a/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml
@@ -25,6 +25,7 @@
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+
<bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" id="serviceBean"/>
<jaxrs:server id="bookservice" address="/bookstore">
<jaxrs:serviceBeans>
@@ -53,6 +54,11 @@
<bean class="org.apache.cxf.systest.jaxrs.CustomWebApplicationExceptionMapper"/>
</jaxrs:providers>
</jaxrs:server>
+ <jaxrs:server id="bookform" bus="cxf2" address="/thebooksform">
+ <jaxrs:serviceBeans>
+ <ref bean="serviceBean"/>
+ </jaxrs:serviceBeans>
+ </jaxrs:server>
<jaxrs:server id="bookservice3" address="/thebooks%203/bookstore">
<jaxrs:serviceBeans>
<ref bean="serviceBean"/>
@@ -134,6 +140,7 @@
<cxf:bus name="cxf2" id="cxf2">
<cxf:properties>
<entry key="skip.default.json.provider.registration" value="true"/>
+ <entry key="cache.http.request.parameters" value="true"/>
</cxf:properties>
</cxf:bus>
<jaxrs:server id="bookJsonp2" address="/jsonp2" bus="cxf2">