March 2019
Intermediate to advanced
242 pages
6h 21m
English
The HttpRequest class encapsulates the information required to be sent across the network to the server by the client. It includes the URI to connect with, headers with a set of variable names and their corresponding values, the timeout value (the time to wait before discarding the request), and the HTTP method to invoke (PUT, POST, GET, or DELETE).
Unlike the HttpClient class, HttpRequest doesn't give you a class instance with the default values, and it makes sense not to. Imagine the URI that the client would connect to if you don't specify it.
Let's create an HttpRequest instance by calling its newBuilder() method and passing a URI to it:
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://www.eJavaGuru.com/")) ...Read now
Unlock full access