gpt4 book ai didi

java - 不支持 Steammobile 协议(protocol)

转载 作者:行者123 更新时间:2023-12-02 04:05:42 24 4
gpt4 key购买 nike

我正在使用适用于 Java 的 Http Apache 客户端,并且正在向 SteamWEB API 向 this steam link 发出请求。 .

这会导致 Http Apache 客户端出现错误:

org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at pl.edu.tirex.helper.http.Http.handleConnection(Http.java:77)
at pl.edu.tirex.helper.http.Http.get(Http.java:60)
at pl.edu.tirex.helper.http.Http.get(Http.java:64)
at pl.edu.tirex.helper.http.Http.get(Http.java:68)
at pl.edu.tirex.steamapi.steamguard.SteamGuard.fetchConfirmations(SteamGuard.java:42)
at pl.edu.tirex.steambot.SteamBOT.<init>(SteamBOT.java:93)
at pl.edu.tirex.steambot.SteamBOT.main(SteamBOT.java:56)
Caused by: org.apache.http.HttpException: steammobile protocol is not supported
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:157)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
... 8 more

我的连接发送结果的代码:

private static final PoolingHttpClientConnectionManager CONNECTION_MANAGER = new PoolingHttpClientConnectionManager();

static
{
CONNECTION_MANAGER.setDefaultMaxPerRoute(2);
CONNECTION_MANAGER.setConnectionConfig(new HttpHost("https://steamcommunity.com/", 443, "steammobile"), ConnectionConfig.DEFAULT);
CONNECTION_MANAGER.setMaxTotal(4);
}

public static void main(String[] args)
{
HttpGet httpget = new HttpGet("url");
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).setConnectionManager(CONNECTION_MANAGER).build();
try (CloseableHttpResponse response = httpclient.execute(httpget, this.context))
{
HttpEntity entity = response.getEntity();

try (InputStream instream = entity.getContent())
{
if (handle != null)
{
if (response.getStatusLine().getStatusCode() >= 400)
{
handle.handleError(instream);
}
else
{
handle.handle(instream);
}
}
}
}
catch (HttpHostConnectException | InterruptedIOException | ClientProtocolException ignored)
{

}
}

我该如何处理这个错误?

最佳答案

这些解决方案工作正常:

private static final PoolingHttpClientConnectionManager CONNECTION_MANAGER = new PoolingHttpClientConnectionManager();

static
{
CONNECTION_MANAGER.setDefaultMaxPerRoute(2);
CONNECTION_MANAGER.setMaxTotal(4);
}

public static void main(String[] args)
{
HttpGet httpget = new HttpGet("url");
httpget.addHeader("X-Requested-With", "com.valvesoftware.android.steam.community");
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).setConnectionManager(CONNECTION_MANAGER).build();
try (CloseableHttpResponse response = httpclient.execute(httpget, this.context))
{
HttpEntity entity = response.getEntity();

try (InputStream instream = entity.getContent())
{
if (handle != null)
{
if (response.getStatusLine().getStatusCode() >= 400)
{
handle.handleError(instream);
}
else
{
handle.handle(instream);
}
}
}
}
catch (HttpHostConnectException | InterruptedIOException | ClientProtocolException ignored)
{

}
}

关于java - 不支持 Steammobile 协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34299604/

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