Azure Core Vert.x HTTP plugin library for Java - version 1.3.0

Azure Core Vert.x HTTP client is a plugin for the azure-core HTTP client API.

Getting started

Prerequisites

Include the package

By default, this transport uses Vert.x 4.5 and Netty 4.1 to support Java 8. It also supports Vert.x 5.0, 5.1 (5.1.1 or later), and 5.2 on Java 11 or later when your application selects one of these Vert.x versions and its compatible transitive dependencies, including Netty 4.2. Vert.x 5.1.0 has an upstream regression that rejects disabled connection timeouts; use 5.1.1 or a later patch release in the 5.1 series instead. Keep Vert.x and Netty versions consistent across your application. Do not combine the default Vert.x 4.5/Netty 4.1 dependencies with the Netty 4.2-based azure-core-http-netty library on the same classpath.

Include the BOM file

Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number. To learn more about the BOM, see the AZURE SDK BOM README.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-sdk-bom</artifactId>
            <version>{bom_version_to_target}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

and then include the direct dependency in the dependencies section without the version tag.

<dependencies>
  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core-http-vertx</artifactId>
  </dependency>
</dependencies>

Include direct dependency

If you want to take dependency on a particular version of the library that is not present in the BOM, add the direct dependency to your project as follows.

<dependencies>
  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core-http-vertx</artifactId>
    <version>1.3.0</version>
  </dependency>
</dependencies>

Key concepts

An explicit request Host header overrides the HTTP authority without changing the connection destination specified by the request URL. With HTTP/1.1 it is sent as Host; with HTTP/2 its value is passed unchanged as :authority instead of sending a conflicting Host header. Requests without an explicit Host continue to use the URL's authority.

Examples

The following sections provide several code snippets covering some of the most common client configuration scenarios.

Create a Simple Client

Create a Vert.x HttpClient.

HttpClient client = new VertxHttpClientBuilder().build();

Create a Vert.x HttpClient using a connection timeout of 60 seconds.

HttpClient client = new VertxHttpClientBuilder().connectTimeout(Duration.ofSeconds(60)).build();

Create a Client with Proxy

Create a Vert.x client that is using a proxy.

HttpClient client = new VertxHttpClientBuilder()
    .proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("<proxy-host>", 8888)))
    .build();

Create an HttpClient with custom maxHeaderSize

Create a Vert.x HttpClient that uses a custom maxHeaderSize. Use this sample if you're seeing an error such as

io.netty.handler.codec.http.TooLongHttpHeaderException: HTTP header is larger than 8192 bytes.

(This is a Netty exception as maxHeaderSize is flowed through to Netty.)

// Constructs an HttpClient with a modified max header size.
// This creates a Vert.x HttpClient with a max headers size of 256 KB.
// NOTE: If httpClientOptions is set, all other options set in the VertxHttpClientBuilder will be ignored.
HttpClient httpClient = new VertxHttpClientBuilder()
    .httpClientOptions(new HttpClientOptions().setMaxHeaderSize(256 * 1024))
    .build();

Next steps

Get started with Azure libraries that are built using Azure Core.

Troubleshooting

If you encounter any bugs, please file issues via GitHub Issues or checkout StackOverflow for Azure Java SDK.

Enabling Logging

Azure SDKs for Java provide a consistent logging story to help aid in troubleshooting application errors and expedite their resolution. The logs produced will capture the flow of an application before reaching the terminal state to help locate the root issue. View the logging wiki for guidance about enabling logging.

Contributing

For details on contributing to this repository, see the contributing guide.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request