forked from wesleyegberto/java-new-features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetRequestTest.java
More file actions
16 lines (14 loc) · 656 Bytes
/
GetRequestTest.java
File metadata and controls
16 lines (14 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.io.IOException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
public class GetRequestTest {
public static void main(String[] args) throws IOException, InterruptedException {
HttpRequest request = HttpBinRequestBuilder.createGetRequest();
HttpClient httpClient = HttpClientBuilderTest.createHttpClient();
// HttpClient#send is blocking; the body is kept in memory to be processed
HttpResponse<String> httpResponse = httpClient.send(request, BodyHandlers.ofString());
System.out.println("Response: " + httpResponse.body());
}
}