I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE COURSE

This is a comprehensive guide to using Apache HttpClient 4 – from starting out to advanced configuration and best practices.

1. HttpClient Basics

Learn the basics of sending a Request, receiving and interpreting the Response and configure the Client for basic usage.

 

2. Advanced Usage

Go into more advanced usecases of configuring the client with SSL, Custom Cookies, different types of Requests, etc.

The implementation of all these examples and code snippets can be found in my github project – this is an Eclipse based project, so it should be easy to import and run as it is.

I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE LESSONS

Sort by:   newest | oldest | most voted
Fosho Law
Guest

Would you still suggest using HttpClient 4 over Spring’s RestTemplate or Feign? If so, could you elaborate why?

Eugen Paraschiv
Guest
Hey Fosho – HttpClient gives you a good base. RestTemplate is a bit higher level but doesn’t have the full flexibility of the HttpClient. And I haven’t used Feign yet (it’s on my list to explore). Generally speaking, it’s not that I recommend HttpCient – but it’s certainly very mature and highly flexible, which most other clients still aren’t). My suggestion is – if you prefer the syntax of another client, so a quick spike to try it out. You may find that it handles everything you need perfectly fine. And if you do need more control – then the… Read more »
Fosho Law
Guest

Thanks for the reply. Always appreciate when blog authors actually reply 🙂

Can you briefly name a few things that HttpClient gives you more control of than RestTemplate? (I’m curious because I usually use RestTemplate)

Eugen Paraschiv
Guest
Yeah, me to – that’s why I do it 🙂 So, there are many small things – mainly because these operate at different abstraction levels. And of course one of the implementations that RestTemplate eventually uses is based on the HttpClient. So, if you’re doing things that are more non-standard – such as sending a DELETE request with a body, fine-tuning the connection pool, configuring keey-alives, keeping track of sessions, etc – essentially anything that’s more low level HTTP – then you’re going to have an easier working with the HttpClient. That’s not to say that all of these things… Read more »
Fosho Law
Guest

I see! Thanks for the insightful reply!

Gennadii Sirtsov
Guest

Hi, do you an article about configuring logging for Apache HC?

Grzegorz Piwowarek
Guest

No, we did not. Thanks for the suggestion, I will add this idea to our “content calendar”.