Skip to content

Comments

feat!: Make HTTP client pluggable with abstract base classes#641

Open
vdusek wants to merge 5 commits intomasterfrom
feature/pluggable-http-client
Open

feat!: Make HTTP client pluggable with abstract base classes#641
vdusek wants to merge 5 commits intomasterfrom
feature/pluggable-http-client

Conversation

@vdusek
Copy link
Contributor

@vdusek vdusek commented Feb 24, 2026

Summary

  • Introduce HttpClient and HttpClientAsync ABCs that users can extend to provide custom HTTP client implementations via ApifyClient(http_client=...) and ApifyClientAsync(http_client=...)
  • Factor impit-specific logic into ImpitHttpClient/ImpitHttpClientAsync, keeping _base.py free of any impit dependency
  • Add HttpResponse protocol with full streaming support (iter_bytes, aiter_bytes, read, aread, close, aclose)
  • Export all public types (HttpClient, HttpClientAsync, HttpResponse, ImpitHttpClient, ImpitHttpClientAsync) from apify_client

Issue

Test plan

  • CI passes

Introduce `HttpClient` and `HttpClientAsync` ABCs that users can extend
to provide custom HTTP client implementations. Factor impit-specific
logic into `ImpitHttpClient`/`ImpitHttpClientAsync`, merge response
protocol into `_base.py`, add streaming methods to `HttpResponse`
protocol, export all public types from `__init__.py`, and standardize
docstring quoting to single backticks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Feb 24, 2026
@vdusek vdusek self-assigned this Feb 24, 2026
@vdusek vdusek requested a review from Pijukatel February 24, 2026 10:08
@github-actions github-actions bot added this to the 135th sprint - Tooling team milestone Feb 24, 2026
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Feb 24, 2026
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.67%. Comparing base (7895a4e) to head (f5ab55e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/apify_client/_http_clients/_base.py 92.85% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #641       +/-   ##
===========================================
+ Coverage   75.60%   96.67%   +21.07%     
===========================================
  Files          45       45               
  Lines        4271     4306       +35     
===========================================
+ Hits         3229     4163      +934     
+ Misses       1042      143      -899     
Flag Coverage Δ
integration 94.70% <85.48%> (?)
unit 75.94% <96.77%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title refactor!: Make HTTP client pluggable with abstract base classes feat!: Make HTTP client pluggable with abstract base classes Feb 24, 2026
@vdusek vdusek requested a review from janbuchar February 24, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to pass own http_client to ApifyClient and ApifyClientAsync

1 participant