Skip to main content

All Questions

1 vote
1 answer
784 views

generate CURL from java.net.http.HttpRequest

is there a good way to generate curl from java.net.http.HttpRequest? It seems like there is no good way to get the body (if there is a body), the closest thing to it is bodyPublisher() that returns ...
Roy Ash's user avatar
  • 1,126
0 votes
1 answer
2k views

Java HttpClient synchronous vs asynchronous request

The Java HttpClient can send either a synchronous or an asynchronous request. The synchronous method blocks until a response has been received, while the asynchronous does not. But what does this mean ...
Kotaka Danski's user avatar
1 vote
1 answer
2k views

How to measure the elapsed time of ASYNC sent HTTPRequest with Java 11 standard HTTPClient?

In one method, I create and send some HTTPRequests async, and add the CF to a list: // HTTPClient is Java11 standard, package java.net.http; CompletableFuture<HttpResponse<String>> ...
rranke's user avatar
  • 33
15 votes
1 answer
17k views

Java 11 HttpRequest with PATCH method

I try to use the java 11 HttpRequest to call the msgraph webservice using the method PATCH: import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; ...
laloune's user avatar
  • 693
3 votes
2 answers
13k views

How to add headers based on multiple conditions to HttpRequest Java 11?

I'm learning the java.net.http api, trying to download a file given a range of bytes already downloaded. For this the range header can be used (supposing the server supports such feature). Using org....
tec's user avatar
  • 1,149
18 votes
2 answers
11k views

How to read the body of a HttpRequest in Java 11?

In a test, I'd like to look inside the body of a HttpRequest. I'd like to get the body as a string. It seems that the only way to do that, is to subscribe to the BodyPublisher but how does that work?
progonkpa's user avatar
  • 3,948
3 votes
1 answer
11k views

Java HttpRequest timeout unexpectedly throwing HttpConnectTimeoutException

Using the new java.net.http package released with JDK 11, an HttpRequest has been assembled with a deliberately low response timeout: HttpRequest.Builder builder = HttpRequest.newBuilder(...
Bobulous's user avatar
  • 13.2k
7 votes
1 answer
3k views

Can't make more than one request on java.net.http.HttpClient or will receive: javax.net.ssl.SSLHandshakeException

I was testing out the new HttpClient from Java 11 and came across the following behaviour: I am making two Async requests to a public REST API for testing and tried it with one client and two ...
JamesJose's user avatar