Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 381226B05 for ; Wed, 18 May 2011 18:06:53 +0000 (UTC) Received: (qmail 5309 invoked by uid 500); 18 May 2011 18:06:53 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 5253 invoked by uid 500); 18 May 2011 18:06:53 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 5246 invoked by uid 99); 18 May 2011 18:06:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2011 18:06:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2011 18:06:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B85142388A38; Wed, 18 May 2011 18:06:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1124361 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Date: Wed, 18 May 2011 18:06:31 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110518180631.B85142388A38@eris.apache.org> 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>( 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",