smallufo created HTTPCLIENT-2166:
------------------------------------
Summary: httpclient5 5.1 incorrectly encode character
Key: HTTPCLIENT-2166
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2166
Project: HttpComponents HttpClient
Issue Type: Bug
Components: HttpClient (classic)
Affects Versions: 5.1
Reporter: smallufo
Attachments: appengine.png
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 :
{code:java}
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}"
}
}
}
{code}
When `testV4` runs , it correctly encode é to %C3%A9 in the URL. And GAE
console shows correct query string :
{code:java}
myapp.ProxyServlet doGet: url = https://google.com/search?q=é{code}
But when testV5 runs , it incorrectly encode é to %E9 . In GAE console it shows
:
{code:java}
myapp.ProxyServlet doGet: url = https://google.com/search?q=�
{code}
The screen shot is below :
!appengine.png!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]