Author: sergeyb
Date: Wed May 18 18:06:31 2011
New Revision: 1124361
URL: http://svn.apache.org/viewvc?rev=1124361&view=rev
Log:
Merged revisions 1124357 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1124357 | sergeyb | 2011-05-18 19:03:23 +0100 (Wed, 18 May 2011) | 1 line
[CXF-3531] Returning 415 in case of malformed Content-Types
........
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 18 18:06:31 2011
@@ -1 +1 @@
-/cxf/trunk:1099767,1100898,1101399,1102198,1103904,1104144,1104180,1104217,1104230
+/cxf/trunk:1099767,1100898,1101399,1102198,1103904,1104144,1104180,1104217,1104230,1124357
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1124361&r1=1124360&r2=1124361&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Wed May 18 18:06:31 2011
@@ -302,9 +302,14 @@ public final class JAXRSUtils {
new TreeMap<OperationResourceInfo, MultivaluedMap<String, String>>(
new OperationResourceInfoComparator(message, httpMethod));
- MediaType requestType = requestContentType == null
+ MediaType requestType;
+ try {
+ requestType = requestContentType == null
? ALL_TYPES :
MediaType.valueOf(requestContentType);
-
+ } catch (IllegalArgumentException ex) {
+ throw new WebApplicationException(ex, 415);
+ }
+
int pathMatched = 0;
int methodMatched = 0;
int consumeMatched = 0;
Modified:
cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1124361&r1=1124360&r2=1124361&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++
cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Wed May 18 18:06:31 2011
@@ -21,6 +21,7 @@ package org.apache.cxf.systest.jaxrs;
import java.io.File;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
@@ -581,7 +582,21 @@ public class JAXRSClientServerBookTest e
+ "parameter, static valueOf(String) or
fromString(String) methods",
"*/*", 500);
}
-
+
+ @Test
+ public void testWrongContentType() throws Exception {
+ // can't use WebClient here because WebClient plays around with the
Content-Type
+ // (and makes sure it's syntactically correct) before sending it to
the server
+ String endpointAddress = "http://localhost:" + PORT +
"/bookstore/unsupportedcontenttype";
+ URL url = new URL(endpointAddress);
+ HttpURLConnection urlConnection =
(HttpURLConnection)url.openConnection();
+ urlConnection.setReadTimeout(30000); // 30 seconds tops
+ urlConnection.setConnectTimeout(30000); // 30 second tops
+ urlConnection.addRequestProperty("Content-Type", "MissingSeparator");
+ urlConnection.setRequestMethod("POST");
+ assertEquals(415, urlConnection.getResponseCode());
+ }
+
@Test
public void testExceptionDuringConstruction() throws Exception {
getAndCompare("http://localhost:" + PORT +
"/bookstore/exceptionconstruction?p=1",