incubator-awf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sleme...@apache.org
Subject svn commit: r1241706 - in /incubator/deft/trunk/src: main/java/org/apache/deft/web/http/HttpRequestImpl.java test/java/org/apache/deft/web/http/HttpRequestParserTest.java
Date Tue, 07 Feb 2012 23:54:46 GMT
Author: slemesle
Date: Tue Feb  7 23:54:46 2012
New Revision: 1241706

URL: http://svn.apache.org/viewvc?rev=1241706&view=rev
Log:
DEFT-196 - Integrate URL encoded parameters patch

Modified:
    incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java
    incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestParserTest.java

Modified: incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java?rev=1241706&r1=1241705&r2=1241706&view=diff
==============================================================================
--- incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java (original)
+++ incubator/deft/trunk/src/main/java/org/apache/deft/web/http/HttpRequestImpl.java Tue Feb
 7 23:54:46 2012
@@ -19,7 +19,9 @@
  */
 package org.apache.deft.web.http;
 
+import java.io.UnsupportedEncodingException;
 import java.net.InetAddress;
+import java.net.URLDecoder;
 import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
@@ -362,8 +364,13 @@ public class HttpRequestImpl implements 
                 // We need to check if the parameter has a value associated with
                 // it.
                 if (keyValueArray.length > 1) {
-                    builder.put(keyValueArray[0], keyValueArray[1]); // name,
-                    // value
+                	String value = keyValueArray[1];
+                	try {
+                		value = URLDecoder.decode(value, "UTF-8");
+                	} catch (UnsupportedEncodingException e) {
+                		// Should not happen
+                	}
+                	builder.put(keyValueArray[0], value);
                 }
             }
 

Modified: incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestParserTest.java
URL: http://svn.apache.org/viewvc/incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestParserTest.java?rev=1241706&r1=1241705&r2=1241706&view=diff
==============================================================================
--- incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestParserTest.java
(original)
+++ incubator/deft/trunk/src/test/java/org/apache/deft/web/http/HttpRequestParserTest.java
Tue Feb  7 23:54:46 2012
@@ -19,16 +19,19 @@
  */
 package org.apache.deft.web.http;
 
-import org.apache.deft.util.ArrayUtil;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.deft.util.HttpRequestHelper;
 import org.apache.deft.util.HttpUtil;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-
-import java.nio.ByteBuffer;
-import java.util.*;
-
 import static org.junit.Assert.*;
 
 public class HttpRequestParserTest {
@@ -145,6 +148,18 @@ public class HttpRequestParserTest {
         assertEquals(null, request.getParameter("firstname"));
         assertEquals(null, request.getParameter("lastName"));
     }
+    
+    @Test
+    public void testEncodedParametersValue() {
+        HttpRequestHelper helper = new HttpRequestHelper();
+        helper.addGetParameter("email", "name%40server");
+
+        HttpRequest request = parser.parseRequestBuffer(helper.getRequestAsByteBuffer());
+        Map<String, Collection<String>> params = request.getParameters();
+
+        assertEquals(1, getSize(params));
+        assertEquals("name@server", request.getParameter("email"));
+    }
 
     @Test
     public void testMultipleParametersWithAndWithoutValue() {



Mime
View raw message