gpt4 book ai didi

java - HttpGet get = new HttpGet(url);给予异常(exception)

转载 作者:搜寻专家 更新时间:2023-10-31 19:38:25 26 4
gpt4 key购买 nike

我正在尝试做一件非常简单的事情,几天前它还在工作。

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

出现以下错误

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)

我之前使用过时的客户端遇到过这个错误,我将其更改为使用 HTTPClientBuilder。我不确定它为什么在 HTTPGet 上给出。非常感谢任何帮助。

最佳答案

这是 apache httpclient 的一个错误,版本 4.4 beta 1 有这个错误,但版本 4.3.6 对我来说工作正常。

如果您使用的是 maven,请在 pom 中使用以下内容:

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

并且在他们修复此错误之前不要将其更新到 4.4。

关于java - HttpGet get = new HttpGet(url);给予异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26187341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com