Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Invalid
-
5.1
-
None
-
None
Description
I build a proxy server on GAE which receives 'url' parameter , and retrieve content .
It works well when client uses httpClient 4.5 , but after httpClient upgrading to 5.1 , I found it has problems encoding character.
Full test code :
import mu.KotlinLogging import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.HttpClientBuilder import kotlin.test.Test class ApacheHttpClientTest { private val logger = KotlinLogging.logger { } val url = "https://myProject.appspot.com/proxy?url=https://google.com/search?q=é" @Test fun testV4() { val httpClient = HttpClientBuilder.create().build() val httpGet = HttpGet(url) logger.info { "httpGet = $httpGet" } logger.info { "statusCode = ${httpClient.execute(httpGet).statusLine.statusCode}" } } @Test fun testV5() { val httpClient = org.apache.hc.client5.http.impl.classic.HttpClientBuilder.create().build() val httpGet = org.apache.hc.client5.http.classic.methods.HttpGet(url) logger.info { "httpGet = $httpGet" } logger.info { "code = ${httpClient.execute(httpGet).code}" } } }
When `testV4` runs , it correctly encode é to %C3%A9 in the URL. And GAE console shows correct query string :
myapp.ProxyServlet doGet: url = https://google.com/search?q=é
But when testV5 runs , it incorrectly encode é to %E9 . In GAE console it shows :
myapp.ProxyServlet doGet: url = https://google.com/search?q=�
The screen shot is below :