Skip to content

Support consumer-supplied HttpClient instance #26

@rammrain

Description

@rammrain

Summary

Allow SDK consumers to supply their own java.net.http.HttpClient instance to MontonioHttpClient, enabling shared connection pools, custom proxy/TLS configuration, and other HttpClient customizations.

Background

During the design of #11, consumer-supplied HttpClient was explicitly deferred (design decision #1) to keep the initial implementation simple. The package-private constructor already accepts an HttpClient parameter for testability — this issue is about making that capability part of the public API.

Requirements

  • Make the MontonioHttpClient(MontonioSdkConfiguration, HttpClient) constructor public
  • When a consumer supplies their own HttpClient, connectTimeout from configuration is not applied (the consumer's HttpClient settings take precedence)
  • The single-arg constructor remains the default path, creating an internal HttpClient with configuration-based timeouts
  • Document the two construction modes

Refs

  • docs/plans/2026-04-10-http-client-design.md — design decision Initial setup #1
  • initial-docs/project2.md — "The SDK must allow the consumer to supply their own HTTP client or provide a default"

Testing

  • Verify consumer-supplied HttpClient is used for requests
  • Verify default constructor still creates its own HttpClient with connectTimeout

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions