Return-Path: Delivered-To: apmail-hc-commits-archive@www.apache.org Received: (qmail 87636 invoked from network); 6 Oct 2009 13:04:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Oct 2009 13:04:05 -0000 Received: (qmail 7031 invoked by uid 500); 6 Oct 2009 13:04:04 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 7000 invoked by uid 500); 6 Oct 2009 13:04:04 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 6990 invoked by uid 99); 6 Oct 2009 13:04:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Oct 2009 13:04:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 06 Oct 2009 13:04:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4A2E223888CE; Tue, 6 Oct 2009 13:03:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r822258 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/client/utils/URLEncodedUtils.java test/java/org/apache/http/client/utils/TestURLEncodedUtils.java Date: Tue, 06 Oct 2009 13:03:40 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091006130340.4A2E223888CE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Tue Oct 6 13:03:39 2009 New Revision: 822258 URL: http://svn.apache.org/viewvc?rev=822258&view=rev Log: HTTPCLIENT-880: Check for correct content-type in URLEncodedUtils not working for encoding-suffixes Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java?rev=822258&r1=822257&r2=822258&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java Tue Oct 6 13:03:39 2009 @@ -40,6 +40,7 @@ import org.apache.http.annotation.Immutable; import org.apache.http.Header; +import org.apache.http.HeaderElement; import org.apache.http.HttpEntity; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; @@ -113,8 +114,18 @@ * application/x-www-form-urlencoded. */ public static boolean isEncoded (final HttpEntity entity) { - final Header contentType = entity.getContentType(); - return (contentType != null && contentType.getValue().equalsIgnoreCase(CONTENT_TYPE)); + Header h = entity.getContentType(); + if (h != null) { + HeaderElement[] elems = h.getElements(); + if (elems.length > 0) { + String contentType = elems[0].getName(); + return contentType.equalsIgnoreCase(CONTENT_TYPE); + } else { + return false; + } + } else { + return false; + } } /** Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java?rev=822258&r1=822257&r2=822258&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java Tue Oct 6 13:03:39 2009 @@ -118,6 +118,9 @@ entity.setContentType(URLEncodedUtils.CONTENT_TYPE); assertTrue(URLEncodedUtils.isEncoded(entity)); + entity.setContentType(URLEncodedUtils.CONTENT_TYPE + "; charset=US-ASCII"); + assertTrue(URLEncodedUtils.isEncoded(entity)); + entity.setContentType("text/test"); assertFalse(URLEncodedUtils.isEncoded(entity)); }