Questions tagged [java-http-client]

This tag should be used for questions which relate specifically to the new JDK 11 `java.net.http` package which includes new classes and interfaces such as HttpClient, HttpRequest, HttpResponse, and WebSocket. This tag should not be used for questions which relate to HTTP handling with the older `java.net` package. This tag can be used for questions about the incubator versions of this package, but do make the JDK version clear in such cases.

This tag should be used for questions which relate specifically to the new Java HTTP Client and WebSocket APIs in package java.net.http which was formally introduced in JDK 11 and includes new classes and interfaces such as HttpClient, HttpRequest, HttpResponse, and WebSocket.

This tag should not be used for questions which relate to HTTP handling with the older java.net package, and it should not be used for questions about third-party HTTP libraries (such as Apache HttpClient, org.apache.http). Search the tags page for tags specific to third-party HTTP libraries.

Note that an incubator version of this new framework was included in JDK 9 and JDK 10. There are significant differences between the incubator versions and the finalised version which was released in JDK 11.

This tag can be used to ask questions about the incubator versions of this new package, but in such cases the question should clearly state the JDK version and make it clear that an incubator version of the framework is being discussed. Such questions should also be tagged with or to make it clear that an older JDK is being used.

179 questions
0
votes
1 answer

Making a request to AWS APIGateway API (with IAM permissions)

I'm a bit inexperienced with Java so that may be my main issue but I'm trying to make an API request to an API that was generated by AWS's API Gateway. The API can only be executed by specific IAM roles. The issue I'm having is that I can't figure…
dredbound
  • 1,579
  • 3
  • 17
  • 27
0
votes
0 answers

How to include a ? in Java 11 HTTP Client URL?

I have a URL from a third party so no option of removing the nasty characters. For security purposes I have put a dummy company in mybadurl.com and also replaced the account number with…
Sankster
  • 13
  • 4
0
votes
2 answers

Flickering HttpClient sometimes throwing IOException

I'm using java.net.http.HttpClient.newHttpClient() under Java 19 (Temurin) and perform sendAsync(...) requests from different treads on the same instance. I assume this is ok, as the javadoc states: Once built, an HttpClient is…
Itchy
  • 2,263
  • 28
  • 41
0
votes
0 answers

Java built-in HttpClient doesn't remove subscribers fast enough

I have the following code: import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import…
Roy Ash
  • 1,078
  • 1
  • 11
  • 28
0
votes
0 answers

Cannot connect to Spring WebSocket server due to null Upgrade Header

I created a WebSocket server using Java Spring, which worked correctly when connecting via ws://localhost:8080/socket and ws://localhost:30019/socket. However, when I attempt to upload the socket to a host and connect to it via…
KingsDev
  • 654
  • 5
  • 21
0
votes
0 answers

Java HTTP POST Request ignoring Request Body

I have a working Python code to send simple post requests which is as follow: def PythonPostRequest(): data = {'appReceiptNum':'LIN2190351771'} response = requests.post('https://egov.uscis.gov/casestatus/mycasestatus.do', data=data) …
0
votes
0 answers

POST multiple requests using a List of payloads in Java for sending HttpRequest

I have a payload utility class where I am iterating over a list of payloads (which are in a json file). There is currently one way to identify an individual payload and that is seen below (Product_Div and Product_SubDiv are two individual…
wheelerlc64
  • 435
  • 2
  • 5
  • 17
0
votes
0 answers

Send Multiple POST Requests and get Response with Java HttpClient

I am looking for functionality to send multiple requests each with different request body payloads, and I am unable to find a way to do that whether sequentially or concurrently. It only works below if I do not loop through the list of payloads and…
wheelerlc64
  • 435
  • 2
  • 5
  • 17
0
votes
1 answer

How to skip intermediary status codes (like 103) with java.net.http.HttpClient and read only the final status code

I have a server which replies first with status code 103 ( and some headers) and then with 200 ( plus some other headers) curl -I output below: HTTP/2 103 link: ; rel=preconnect, ; crossorigin;…
humbletrader
  • 396
  • 2
  • 10
0
votes
0 answers

Java HttpClient hangs after request takes too long to respond

I have an API that process a lot of information by calling another API. So for example, when the process starts in the API A, it makes a lot of http requests do the API B. It works fine for most requests, but some of them sometimes takes a lot of…
Gustavo Cesário
  • 1,310
  • 1
  • 12
  • 23
0
votes
1 answer

Which Java client to use for calculating HTTP performance metrics like TCP connection time, Time to first byte, TLS handshake time etc

I am looking for a Java HTTP Async client which can be used to get performance metrics like TCP connection time, Time to first byte, TLS handshake time for an endpoint. I looked into latest java.net.http module but it does not seem to have any such…
Mary123
  • 11
  • 4
0
votes
1 answer

java.net.http.HttpClient not POST'ing data to Server?

I'm trying to write a simple HTTP Client & Server using the new (JDK 11) HttpClient. JDK.: OpenJDK 17.0.0 The Client is connecting to the Server but doesn't seem to be POST'ing any data. After the Server receives the incoming Connection, it tries to…
Dave The Dane
  • 650
  • 1
  • 7
  • 18
0
votes
1 answer

How to return a CompletableFuture> from a CompletableFuture>

I am attempting to implement a generic REST client as below. I have my own model to represent the HTTP response as Response T . Here T is the return type from the service call and it could be just T or List of Ts. Below code does not compile and…
Rasika
  • 312
  • 1
  • 7
  • 19
0
votes
1 answer

Google Cloud Function can't call Cloud Function Service because of protocol error in jdk.internal.net.http.HttpClientImpl

I have a Google Cloud Function that uses the java.net.http.HttpClient to send a GET request to the URL https://userinfo-service-55555xyz-ew.a.run.app (that is represting my Cloud Run Service). Both the function and the run service are located in…
xetra11
  • 7,671
  • 14
  • 84
  • 159
0
votes
0 answers

Intermitent "Received RST_STREAM: Not an error" observed when calling send on java.net.http.HttpClient

I've noticed recently a weird, intermittent error: "Received RST_STREAM: Not an error" which seems to come from java when calling send on java.net.http.HttpClient. Googling it, I found similar errors but not exactly with the same message. Any idea…
Yonoss
  • 1,242
  • 5
  • 25
  • 41