[
https://issues.apache.org/jira/browse/HTTPCLIENT-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17652223#comment-17652223
]
Oleg Kalnichevski commented on HTTPCLIENT-2254:
-----------------------------------------------
[~aaukhatov] No need to be sad. Use {{BasicClassicHttpRequest}} from the core
module and you should be able to pass any rubbish as a request path:
{code:java}
try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
final BasicClassicHttpRequest httpget = new BasicClassicHttpRequest("GET",
new HttpHost("httpbin.org"), "типа запрос");
httpclient.execute(httpget, response -> {
System.out.println("----------------------------------------");
System.out.println(httpget + "->" + new StatusLine(response));
EntityUtils.consume(response.getEntity());
return null;
});
}
{code}
Be prepared, though, that a well-behaved server can tell you to go and play
with your self
{noformat}
2022-12-27 12:12:40,802 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 >> GET типа запрос HTTP/1.1
2022-12-27 12:12:40,802 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 >> Accept-Encoding: gzip, x-gzip, deflate, br
2022-12-27 12:12:40,802 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 >> Host: httpbin.org
2022-12-27 12:12:40,803 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 >> Connection: keep-alive
2022-12-27 12:12:40,803 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 >> User-Agent: Apache-HttpClient/5.2.1-SNAPSHOT (Java/1.8.0_342)
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << HTTP/1.1 400 Bad Request
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << Server: awselb/2.0
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << Date: Tue, 27 Dec 2022 11:12:40 GMT
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << Content-Type: text/html
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << Content-Length: 122
2022-12-27 12:12:41,000 DEBUG [main][org.apache.hc.client5.http.headers]
http-outgoing-0 << Connection: close
{noformat}
Oleg
> Allow to use java.net.URL to create any instance of HttpUriRequest
> ------------------------------------------------------------------
>
> Key: HTTPCLIENT-2254
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2254
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient (classic)
> Affects Versions: 5.2.1
> Reporter: Artur
> Priority: Major
>
> h3. Context
> We use Apache Http Client v5 to communicate with a bunch of services. So the
> API of a remote service (public, we don't maintain that) in some cases
> requires using uncoded query parameter values and these values can be not
> ASCII.
>
> h3. Example
>
> This is the URL that we have to call
>
> {{https://remote-service/api/directory/c6eb9ba1-a862-4f50-81a3-bf9f3f5cc94c/items?DirRef=path/someParams&Reference=значение
> с кириллицей в имени}}
> Creating an instance of
> {{URI.create("https://remote-service/api/directory/c6eb9ba1-a862-4f50-81a3-bf9f3f5cc94c/items?DirRef=path/someParams&Reference=значение
> с кириллицей в имени"); }}
>
> throws an exception java.net.URISyntaxException
> However, if we use an instance of java.net.URL it allows us to create
>
> {{new
> URL("https://remote-service/api/directory/c6eb9ba1-a862-4f50-81a3-bf9f3f5cc94c/items?DirRef=path/someParams&Reference=значение
> с кириллицей в имени");}}
> h3.
> Suggestion
>
> Could you adjust creating request instances for using java.net.URL class
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]