java-http-client Questions

4

Solved

The HttpClient introduced experimentally in Java 9 is now stable in Java 11, but not surprisingly, very few projects seem to actually use it. Documentation is almost non-existing. One of the most ...
Dextrad asked 8/11, 2018 at 19:43

2

JDK11 introduced a new HTTP Client, with many features that lacks in traditional java.net.HttpURLConnection class. First question that I encountered with is how to properly enable logging in newly ...
Erupt asked 17/2, 2019 at 7:57

6

Solved

I'm trying to send a POST request using the new http client api. Is there a built in way to send parameters formatted as x-www-form-urlencoded ? My current code: HttpRequest request = HttpRequest...
Panjabi asked 23/6, 2019 at 23:24

0

Currently using the Java 11 HttpClient to make http requests and it appears there isn't an obvious way to read response trailers. These responses are streamed back to the client - the Java 11 HttpC...
Placia asked 20/2, 2024 at 17:41

5

Solved

I'm looking for examples using a plain JDK11+ http client reading server sent events, without extra dependencies. I can't find anything about sse in the documentation either. Any hints?
Zoochore asked 20/8, 2020 at 8:4

2

Solved

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 wor...
Amanita asked 23/4, 2019 at 17:7

5

Solved

Sometimes it is needed to allow insecure HTTPS connections, e.g. in some web-crawling applications which should work with any site. I used one such solution with old HttpsURLConnection API which wa...
Payroll asked 25/10, 2018 at 11:54

2

I'm looking to use the new HttpClient provided in java 11. It's not clear how to do mutual TLS (2 way auth, where both client and server present a certificate.) Could someone provide an example of ...
Unforgettable asked 21/7, 2020 at 20:19

1

Solved

I'm using Java Corretto 21.0.0.35.1 build 21+35-LTS, and the built-in Java HTTP client to retrieve a response as an InputStream. I'm making parallel requests using virtual threads, and for the most...
Paratroops asked 18/10, 2023 at 11:28

2

Solved

I'm trying to test my code which uses the new Java 11 java.net.http.HttpClient. In my production code I have something like this: HttpClient httpClient = ... (gets injected) HttpRequest request ...
Tamratamsky asked 15/12, 2019 at 10:24

7

Solved

Is there a way to close java.net.http.HttpClient to instantly release resources held by it? Internally it holds a selector, a connection pool and an Executor (when default one is used). However it...
Lahdidah asked 25/12, 2018 at 5:58

2

Solved

When using the java.net.http.HttpClient classes in Java 11 and later, how does one tell the client to follow through an HTTP 303 to get to the redirected page? Here is an example. Wikipedia provide...
Barocchio asked 23/2, 2021 at 0:48

3

I'm trying to use JDK 11 HttpClient to make requests through a corporate proxy which requires authentication by login and password. According to JDK's intro, I'm building an instance of client by m...
Fillender asked 16/11, 2018 at 7:52

2

Solved

Java 11's java.net.http.HttpClient does not seem to check the HTTP status code, except for redirects (if enabled). And all examples found in the wiki and in the Java API documentation always assume...
Tarryn asked 13/5, 2021 at 17:44

2

Solved

We want to migrate all our apache-httpclient-4.x code to java-http-client code to reduce dependencies. While migrating them, I ran into the following issue under Java 11: How to set the socket time...
Palaeobotany asked 27/10, 2020 at 7:52

3

There appears to be very little Java 11 (pure Java non framework based) WebSocket client code examples on the web so I'm hoping StackOverflow can come to the rescue for me once again. This is the ...
Machinery asked 27/3, 2019 at 15:23

2

I am a Web Applications developer using J2EE Technology. I have made extensive use of Oracle's / OpenJDK's HTTP packages, as I find them more comfortable fo development. https://docs.oracle.com/en/...
Protraction asked 28/10, 2021 at 8:9

1

Solved

I've got a program that makes use of the java.net.http.HttpClient, which was introduced in Java 11, to connect and send requests to internal services. These services are mutually authenticated, bot...
Magruder asked 9/10, 2021 at 12:48

3

Solved

I have a problem with deserializing JSON to custom object directly using Java 11 HttpClient::send with custom HttpResponse.BodyHandler. I came across this issue while answering this SO question. V...
Waiver asked 23/8, 2019 at 15:41

2

Solved

How should I deal with servers that hang sending an HTTP response body using the HTTP client included in Java 11 onwards, when I need to handle the response in a streaming fashion? Having read the ...
Tune asked 19/5, 2021 at 11:15

3

Solved

With Java's java.net.HttpURLConnection there is a getResponseMessage() method to retrieve any Reason-Phrase text (as specified by RFC2616 6.1 Status Line). In the newer Java 11 HttpClient, java.net...
Prophet asked 22/8, 2020 at 19:4

1

My problem is that the HttpClient never makes its way to the target. The target is on the same network (so I need no proxy) and it is definitely up. And the timeout was set quite high (120 seconds)...
Absolve asked 25/4, 2021 at 8:42

1

Basically as the title says. Apache HttpClient and Spring RestTemplate allow for defining custom interceptors which wrap around requests/responses and allow for additional (global) modification of ...
Incubate asked 10/12, 2018 at 14:13

2

Solved

In the example below I create one Java 11 httpClient and then create multiple concurrent HttpRequests. Is this bad practice? Should each HttpRequest have its own HttpClient? Is there an upper limi...
Inspect asked 11/10, 2020 at 10:22

0

I saw that in JDK9 there was a support for trailers (the HttpResponse.trailers​() method), but no longer on JDK 10 (the HttpResponse.trailers​() method is absent). I am currently using JDK11 and wh...
Commandant asked 15/9, 2020 at 16:7

© 2022 - 2025 — McMap. All rights reserved.