🇬🇧 Internal workings of an HTTP Client
Most modern applications make an HTTP request one way or the other. However, despite their common usage HTTP clients are difficult to use optimally. This is partially because each environment is different, and also because networking itself is a difficult topic.
At the same time, a properly configured HTTP client could be the difference between a thread-busy server, or a localized error.
I believe understanding the internals of how an HTTP library functions is an invaluable skill. I'd like to talk about the internals of a HTTP client that I know well, Armeria's WebClient.
I believe these topics are not pertinent only to Armeria, and other HTTP clients are implemented with similar concepts in mind.
I'll be discussing how Armeria client is implemented internally. I'll briefly go through the process of making a simple client request. While doing so, I'll touch on how DNS Resolution, Connection Pooling, Protocol Negotiation is implemented. I'll also discuss how the request and response is sent or received over the wire.
Implementing an extensible and performant HTTP client can be a difficult task. I'll introduce how Armeria uses Event Loops, Decorators, and Reactive Streams to achieve this. I will also give code pointers in case anyone would like to go through the Armeria code-base themselves.