HttpGet get = new HttpGet (url); providing exceptions

I am trying to do a very simple thing that worked a couple of days ago.

CloseableHttpClient client = HttpClientBuilder.create().build(); HttpGet get = new HttpGet(url); HttpResponse response = client.execute(get); 

It gives the following error:

 Caused by: java.lang.IllegalStateException: Unsupported cookie spec: default at org.apache.http.cookie.CookieSpecRegistry.getCookieSpec(CookieSpecRegistry.java:110) at org.apache.http.cookie.CookieSpecRegistry$1.create(CookieSpecRegistry.java:163) at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java:157) at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:132) at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:166) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:485) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:878) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:84) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:109) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) 

I encountered this error before using an outdated client, and I changed it to use HTTPClientBuilder. I'm not sure why it gives an HTTPGet. Any help is appreciated.

+5
source share
1 answer

This is a bug from apache httpclient, version 4.4 beta 1 has this error, but version 4.3.6 works fine for me.

If you are using maven, use the following command in pom:

  <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.3.6</version> </dependency> 

And do not upgrade it to 4.4 before fixing this error.

+7
source

Source: https://habr.com/ru/post/1203973/


All Articles