HttpClient Overview

The Hyper-Text Transfer Protocol (HTTP) is perhaps the most significant protocol used on the Internet today. Web services, network-enabled appliances and the growth of network computing continue to expand the role of the HTTP protocol beyond user-driven web browsers, while increasing the number of applications that require HTTP support.

Although the java.net package provides basic functionality for accessing resources via HTTP, it doesn't provide the full flexibility or functionality needed by many applications. HttpClient seeks to fill this void by providing an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations.

Designed for extension while providing robust support for the base HTTP protocol, HttpClient may be of interest to anyone building HTTP-aware client applications such as web browsers, web service clients, or systems that leverage or extend the HTTP protocol for distributed communication.

Documentation

  1. Quick Start - contains simple, complete examples of request execution with the classic, fluent and async APIs.

  2. Examples demonstrating some common as well as more complex use cases

  3. Javadocs

  4. API compatibility reports

Features

  • Standards based, pure Java, implementation of HTTP versions 1.0, 1.1, 2.0
  • Supports encryption with HTTPS (HTTP over SSL) protocol.
  • Pluggable TLS strategies.
  • Transparent message exchanges through HTTP/1.1, HTTP/1.0 and SOCKS proxies.
  • Tunneled HTTPS connections through HTTP/1.1 and HTTP/1.0 proxies, via the CONNECT method.
  • Basic, Digest, Bearer, SCRAM-SHA-256 authentication schemes.
  • HTTP state management and cookie support.
  • Flexible connection management and pooling.
  • Support for HTTP response caching.
  • Transparent content decompression.
  • Support for Unix domain sockets.
  • Source code is freely available under the Apache License.
  • Experimental RFC 9218 prioritization (Priority header & PRIORITY_UPDATE for HTTP/2).
  • Optional observability module** httpclient5-observation) with Micrometer / OpenTelemetry support for request timers/counters,
  • I/O byte counters, connection-pool gauges, and DNS/TLS meters for classic and async clients.
  • Optional Caffeine-based cache backend for in-memory HTTP cache storage.
  • Basic, Digest, Bearer, and SCRAM-SHA-256 authentication schemes.
  • Async transparent content compression and decompression with deflate, gzip, and optional zstd / brotli codecs. See Async content compression & decompression.
  • Async support for RFC 8297 103 Early Hints via a pluggable EarlyHintsListener.
  • Optional SPKI pinning TLS strategy (SpkiPinningClientTlsStrategy) for host / wildcard public-key pinning.
  • Optional Server-Sent Events (SSE) module (httpclient5-sse) for consuming long-lived event streams over HTTP/1.1 and HTTP/2 using the async transport.

Standards Compliance

HttpClient strives to conform to the following specifications endorsed by the Internet Engineering Task Force (IETF) and the internet at large:

  • RFC 9110 - HTTP Semantics
  • RFC 9111 - HTTP Caching
  • RFC 9112 - Hypertext Transfer Protocol Version 1.1 (HTTP/1.1)
  • RFC 9113 - Hypertext Transfer Protocol Version 2 (HTTP/2)
  • RFC 7541 - HPACK: Header Compression for HTTP/2
  • RFC 1945 - Hypertext Transfer Protocol – HTTP/1.0
  • RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax
  • RFC 6265 - HTTP State Management Mechanism (Cookies)
  • RFC 7616 - HTTP Digest Access Authentication
  • RFC 7617 - HTTP ‘Basic’ Authentication Scheme
  • RFC 5861 - HTTP Cache-Control Extensions for Stale Content
  • RFC 2817 - Upgrading to TLS Within HTTP/1.1
  • RFC 9218 - Extensible Prioritization Scheme for HTTP
  • RFC 7804 - Salted Challenge Response HTTP Authentication Mechanism
  • RFC 9218 - Extensible Prioritization Scheme for HTTP (experimental support: Priority header & PRIORITY_UPDATE for HTTP/2)
  • RFC 8297 – Early Hints status code