Skip to content

Make HttpClient testable by allowing Curl and MultiCurl injection and removing external API dependency from tests #400

Description

@armanist

Description

The current HttpClient implementation and its tests relied on real external HTTP APIs, which made the test suite slow, flaky, and environment-dependent.
This change aims to make HttpClient unit-testable in isolation while preserving full backward compatibility and existing behavior.

Requirements

HttpClient changes

  • HttpClient MUST allow injecting a Curl instance into createRequest()
  • HttpClient MUST allow injecting a MultiCurl instance into:
    • createMultiRequest()
    • createAsyncMultiRequest()
  • If no client is injected, HttpClient MUST continue to instantiate Curl / MultiCurl internally (BC preserved)
  • No external HTTP requests should be required to exercise HttpClient logic in tests
  • Public API behavior MUST remain unchanged for existing consumers

Test suite changes

  • All HttpClient unit tests MUST be rewritten to:
    • avoid external APIs
    • avoid real network calls
    • use mocks for Curl and MultiCurl
  • Tests MUST cover:
    • single request flow
    • multi request response normalization (headers, cookies, body)
    • async multi request callback registration
    • error handling for single and multi requests
    • request header interception and case-insensitivity
    • passthrough helpers (info(), url())
  • Tests MUST be deterministic and runnable offline
  • External API–specific assertions MUST be removed

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions