Java – use version 4.0 of httpclient

I want to update the httpclient version in my project The project now uses HTTP 3.1 jar. I need to upgrade version 4.0 I downloaded the repository from here

I changed most of the code, but insisted on using some APIs and methods I have searched a lot with Google, but I can't find the corresponding code. I describe it below:

What is the equivalence of multithreadedhttpconnectionmanager?

I found 4.0 for httpclient X, but it does not exist in version 4.0 This is my old code base for HTTP version 3.1

MultiThreadedhttpconnectionManager connMgr = new MultiThreadedhttpconnectionManager();
    m_client = new HttpClient(connMgr);

    /*
     * Maximum concurrent connections that are allowed to a given
     * domain/host
     */
    m_client.gethttpconnectionManager()
            .getParams()
            .setMaxConnectionsPerHost(
                    HostConfiguration.ANY_HOST_CONfigURATION,maxConcurrentConnections);

    /*
     * 
     * How long to wait before timing out on a http connection
     */
    m_client.gethttpconnectionManager().getParams()
            .setConnectionTimeout(connectionTimeout);

    /*
     * How long to wait before timing out on a socket connection
     */
    m_client.getParams().setSoTimeout(socketTimeout);

Solution

It seems that httpclient 4.0 uses threadsafeclientconnmanager, and poolingclientconnectionmanager is not recommended in version 4.2

I found this in the following post: best practice to use httpclient in multithreaded environment

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>