HTTP Client

port_http_client

This port provides a common interface for using HTTP clients. Many adapters can be developed to use different technologies.

Its main functionalities are:

  • HTTP, HTTPS and HTTP/2 support
  • Mutual TLS
  • Body encoding/decoding
  • Request/response exchange
  • Form submissions
  • Cookie management
  • File uploading/downloading

Install the Dependency

This module is not meant to be used directly. You should include and Adapter implementing this feature (as http_client_ahc) in order to create HTTP clients.

Create an HTTP client

You create an HTTP Client instance with default options as follows:

1
2
3
4
5
6
7
// Adapter injected
Client()
Client("http://host:1234/base")

// Adapter provided explicitly
Client(adapter)
Client(adapter, "http://host:1234/base")

Settings

If you want to configure options for the client, you create it with the following code:

1
2
3
4
5
6
7
8
Client("", ClientSettings(
    contentType = null,
    useCookies = true,
    headers = LinkedHashMap(),
    user = null,
    password = null,
    insecure = false
))

Send simple requests

Requests

Responses

Authorization

Cookies

TLS

Key Store
Trust Store

Mutual TLS

Packages

Name Summary
com.hexagonkt.http.client This package holds the classes that define the HTTP client and its configuration settings.

Index

All Types

Comments