Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating from HttpClient 3.x to 4.x

Tags:

We have some code written using commons-httpclient-3.1 that needs to be converted to 4.1. I'm only somewhat familiar with this and am reading the 4.1 httpclient tutorial now.

I see a couple of posts here (e.g. Converting from HttpClient 3 to 4 but that's about a specific construct). Seems like there should be some docs/examples somewhere showing how to upgrade usage of 3.x to 4.x ?

One specific example: replacing use of org.apache.commons.httpclient.HttpState

like image 848
Cincinnati Joe Avatar asked Jul 07 '11 18:07

Cincinnati Joe


People also ask

Is HttpClient multithreaded?

Concurrent execution of HTTP methodsHttpClient is fully thread-safe when used with a thread-safe connection manager such as MultiThreadedHttpConnectionManager.

Do I need to close HttpClient?

You do not need to explicitly close the HttpClient, however, (you may be doing this already but worth noting) you should ensure that connections are released after method execution. Edit: The ClientConnectionManager within the HttpClient is going to be responsible for maintaining the state of connections.

What is org Apache HttpComponents?

The Apache HttpComponents project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. This project functions under the Apache Software Foundation (http://www.apache.org), and is part of a larger community of developers and users.


1 Answers

I would replace the library jar(s) in your IDE and look for compiler errors to start with. You may wish to go back and check all usages to ensure they are used the same way, and parameters remain as expected (hopefully they didn't switch things around).

Is there a specific piece of code you are unsure how to get working with 4.1?

like image 166
CrackerJack9 Avatar answered Sep 23 '22 13:09

CrackerJack9