Generic Top

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE

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

HttpClient Basics

Advanced Usage

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.

Generic bottom

I just announced the new Learn Spring course, focused on the fundamentals of Spring 5 and Spring Boot 2:

>> CHECK OUT THE COURSE
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Fosho Law
Fosho Law
4 years ago

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

Eugen Paraschiv
4 years ago
Reply to  Fosho Law

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
Fosho Law
4 years ago

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
4 years ago
Reply to  Fosho Law

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
Fosho Law
4 years ago

I see! Thanks for the insightful reply!

Gennadii Sirtsov
Gennadii Sirtsov
3 years ago

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

Grzegorz Piwowarek
Grzegorz Piwowarek
3 years ago

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

Comments are closed on this article!