Junior — Middle
Can the HTTP protocol be considered blocking or non-blocking in the context of request execution?
sobes.tech AI
Answer from AI
The HTTP protocol itself does not define whether it is blocking or non-blocking — it depends on the client and server implementation.
In the context of Java, if using traditional blocking sockets or libraries, HTTP requests will be blocking: the execution thread waits for the server's response.
However, modern libraries and frameworks (for example, HttpClient from Java 11 with asynchronous API, or Netty) allow performing HTTP requests in a non-blocking manner, using asynchronous calls and callbacks or CompletableFuture.
Thus, HTTP can be considered both blocking and non-blocking depending on the tools used and the approach to executing requests.