ok2c commented on a change in pull request #205: URL: https://github.com/apache/httpcomponents-core/pull/205#discussion_r462482959
########## File path: httpcore5/src/main/java/org/apache/hc/core5/net/WWWFormCodec.java ########## @@ -0,0 +1,83 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + +package org.apache.hc.core5.net; + +import java.nio.charset.Charset; +import java.util.List; + +import org.apache.hc.core5.http.NameValuePair; + +/** + * {@code application/x-www-form-urlencoded} codec. + * + * @since 5.1 + */ +public class WWWFormCodec { Review comment: @michael-o Likewise I am not sure I understand the problem. `x-www-form-urlencoded` coding makes use of percent-coding but are not the same thing. ########## File path: httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java ########## @@ -355,8 +440,8 @@ public void assertSetParameters(final Charset charset) throws Exception { } public void assertBuild(final Charset charset, final URI uri) throws Exception { - final String encodedData1 = URLEncodedUtils.encodeFormFields("\"1\u00aa position\"", charset); - final String encodedData2 = URLEncodedUtils.encodeFormFields("Jos\u00e9 Abra\u00e3o", charset); + final String encodedData1 = PercentCodec.encode("\"1\u00aa position\"", charset); Review comment: @michael-o Why? The entire `URLEncodedUtils` got completely messed by mixing up `application/x-www-form-urlencoded` or URI coding logic hence its deprecation. ########## File path: httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java ########## @@ -444,14 +542,14 @@ public void testPathNoLeadingSlash() throws Exception { .setScheme("ftp") .setPath("blah") .build(); - Assert.assertThat(uri, CoreMatchers.equalTo(URI.create("ftp:/blah"))); + MatcherAssert.assertThat(uri, CoreMatchers.equalTo(URI.create("ftp:/blah"))); Review comment: @michael-o I am not sure what extra slash you are referring to. Authority separator? But there is no authority. ########## File path: httpcore5/src/test/java/org/apache/hc/core5/net/TestWWWFormCodec.java ########## @@ -0,0 +1,124 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + +package org.apache.hc.core5.net; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; + +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.NameValuePairListMatcher; +import org.apache.hc.core5.http.message.BasicNameValuePair; +import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; +import org.junit.Test; + +public class TestWWWFormCodec { Review comment: @michael-o Will add it. ########## File path: httpcore5/src/test/java/org/apache/hc/core5/net/TestURIBuilder.java ########## @@ -355,8 +440,8 @@ public void assertSetParameters(final Charset charset) throws Exception { } public void assertBuild(final Charset charset, final URI uri) throws Exception { - final String encodedData1 = URLEncodedUtils.encodeFormFields("\"1\u00aa position\"", charset); - final String encodedData2 = URLEncodedUtils.encodeFormFields("Jos\u00e9 Abra\u00e3o", charset); + final String encodedData1 = PercentCodec.encode("\"1\u00aa position\"", charset); Review comment: @michael-o Why? The entire `URLEncodedUtils` got completely messed by mixing up `application/x-www-form-urlencoded` and URI coding logic hence its deprecation. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org