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
Description
The current
HttpClientimplementation and its tests relied on real external HTTP APIs, which made the test suite slow, flaky, and environment-dependent.This change aims to make
HttpClientunit-testable in isolation while preserving full backward compatibility and existing behavior.Requirements
HttpClientchangesHttpClientMUST allow injecting aCurlinstance intocreateRequest()HttpClientMUST allow injecting aMultiCurlinstance into:createMultiRequest()createAsyncMultiRequest()HttpClientMUST continue to instantiateCurl/MultiCurlinternally (BC preserved)Test suite changes
HttpClientunit tests MUST be rewritten to:CurlandMultiCurlinfo(),url())