Loading topic
java.net.http maps onto a part of it: a request has a method, a URI, headers and an optional body, and a response has a status code, headers and an optional body. Knowing which part is which makes the API eas5 min readjava.net.http call uses, and what each one owns. Later chapters cover each in detail.4 min readHttpClient, HttpRequest, HttpResponse) and can send a basic GET with send. Here you will build one configured client and share it across your whole application.4 min readHttpRequest. It assumes you know Java 11 syntax, HTTP methods and headers, and how HttpClient fits in from the earlier chapters. Sending the request and reading the response come in later chapters. The examples here only build requests and inspect them, so4 min readHttpClient and an HttpRequest, and that you have called client.send(...) at least once. It also assumes you know the basic HTTP status codes and Java generics. Here you will learn what a BodyHandler does, how the built-in handlers differ, and how to pick4 min readHttpClient and an HttpRequest, and that you know how BodyHandlers choose the response type. It also assumes you are comfortable with checked exceptions. Here you will look at what send does, what it returns, and how it fails.3 min readHttpClient and an HttpRequest and call send. It also assumes you know what HTTP status codes and headers are. Here you will work with the HttpResponse object that send returns.4 min readHttpClient and an HttpRequest with a builder, and that you know what a request body and the Content-Type header are. It covers how to attach a body to a request.3 min readHttpClient, send a request with send, and read statusCode() and body(). It also assumes you know Java checked exceptions and the basic HTTP status classes (2xx, 3xx, 4xx, 5xx).4 min readHttpClient and an HttpRequest, send a request with send, and catch checked exceptions. The async section also assumes basic CompletableFuture use.4 min readHttpClient and an HttpRequest, choosing a BodyHandler, and the checked exceptions that send throws. It also assumes a working knowledge of CompletableFuture. You should know what thenApply and join do.4 min readsend, and check the status code. It also assumes you know basic Java records and checked exceptions.3 min readHttpClient and send a request with send, as covered in earlier chapters. It explains how the client handles 3xx responses, what the three redirect policies do, and when to follow redirects yourself.4 min readHttpClient and an HttpRequest, call send, and read the status code. It covers two ways to prove who you are to an HTTP API: setting an Authorization header yourself, and letting the client answer a challenge through an Authenticator.4 min readHttpClient and a request, call send and sendAsync, and use basic CompletableFuture methods such as thenApply and join. It covers why one client should serve your whole application, how to run many requests at once, and how to keep that concurrency un5 min readHttpClient and an HttpRequest, call send, and read a HttpResponse. It also assumes you know the BodyHandlers and BodyPublishers factories from earlier chapters. Here you will see how to move large bodies without holding them in memory.4 min readHttpClient, send a request with send, and read statusCode() and body() from the response. It covers how the client chooses an HTTP version, how to find out which version was used, and when forcing a version is worth doing.3 min readsend and sendAsync. It also assumes you can catch the checked exceptions from the previous chapters and have used CompletableFuture. The java.net.http.HttpClient has no retry feature. Nothing in the builder, the request or the response 4 min readHttpClient.Builder options you need when a plain client isn't enough: corporate proxies, session cookies, private certificate authorities and your own thread pool. It assumes you can already build a client and send requests with send and sendAsync, and that you know the4 min read