不支持 Steammobile 协议

Steammobile protocol is not supported

我正在为 Java 使用 Http Apache Client 并正在向 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)
    {

    }
}