Skip to content

Add Maven dependency for JDK HttpClient; update versions #1441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions articles/java/sdk/http-client-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The following example shows you how to exclude the Netty dependency from a real
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.2.2.</version>
<version>4.9.4</version>
<exclusions>
<exclusion>
<groupId>com.azure</groupId>
Expand All @@ -45,10 +45,18 @@ The following example shows you how to exclude the Netty dependency from a real
</exclusions>
</dependency>

<!-- OkHttp -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-okhttp</artifactId>
<version>1.3.3</version>
<version>1.12.10</version>
</dependency>

<!-- JDK HttpClient -->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-jdk-httpclient</artifactId>
<version>1.0.3</version>
</dependency>
```

Expand All @@ -59,7 +67,7 @@ The following example shows you how to exclude the Netty dependency from a real

When you build a service client, it defaults to using `HttpClient.createDefault()`. This method returns a basic `HttpClient` instance based on the provided HTTP client implementation. In case you require a more complex HTTP client, such as a proxy, each implementation offers a builder that allows you to construct a configured `HttpClient` instance. The builders are `NettyAsyncHttpClientBuilder`, `OkHttpAsyncHttpClientBuilder`, and `JdkAsyncHttpClientBuilder`.

The following examples show how to build `HttpClient` instances using Netty, OkHttp, and the JDK 11 HTTP client. These instances proxy through `http://localhost:3128` and authenticate with user `example` with password `weakPassword`.
The following examples show how to build `HttpClient` instances using Netty, OkHttp, and the JDK HTTP client. These instances proxy through `http://localhost:3128` and authenticate with user `example` with password `weakPassword`.

```java
// Netty
Expand All @@ -74,7 +82,7 @@ HttpClient httpClient = new OkHttpAsyncHttpClientBuilder()
.setCredentials("example", "weakPassword"))
.build();

// JDK 11 HttpClient
// JDK HttpClient
HttpClient client = new JdkAsyncHttpClientBuilder()
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 3128))
.setCredentials("example", "weakPassword"))
Expand Down