Skip to content

feat: Add HTTP CONNECT proxy support (http_connect_proxy=)#2990

Open
ZivBleich wants to merge 1 commit into
dpkp:masterfrom
ZivBleich:ZivBleich/http-connect-proxy
Open

feat: Add HTTP CONNECT proxy support (http_connect_proxy=)#2990
ZivBleich wants to merge 1 commit into
dpkp:masterfrom
ZivBleich:ZivBleich/http-connect-proxy

Conversation

@ZivBleich
Copy link
Copy Markdown

@ZivBleich ZivBleich commented May 25, 2026

Adds http_connect_proxy= to KafkaConsumer, KafkaProducer, and KafkaAdminClient.

HttpConnectWrapper in kafka/http_connect_wrapper.py implements this as a non-blocking state machine satisfying the same three-method contract as Socks5Wrapper: use_remote_lookup, socket, connect_ex.

Also adds kafka/net/__init__.py to fix a packaging bug: pyproject.toml sets namespaces = false, so setuptools only includes subdirectories with __init__.py. Without it, kafka.net is silently excluded from installed wheels.

Tests:

pytest test/net/test_http_connect.py -q
pylint --errors-only kafka/http_connect_wrapper.py kafka/net/__init__.py kafka/net/inet.py kafka/consumer/group.py kafka/producer/kafka.py kafka/admin/client.py test/net/test_http_connect.py

ZivBleich added a commit to ZivBleich/kafka-python that referenced this pull request May 25, 2026
@ZivBleich ZivBleich force-pushed the ZivBleich/http-connect-proxy branch from 0258773 to 3023bbf Compare May 25, 2026 08:41
@ZivBleich ZivBleich marked this pull request as draft May 25, 2026 08:43
Adds http_connect_proxy= parameter to KafkaConsumer, KafkaProducer, and
KafkaAdminClient. Accepts a plain proxy URL string (e.g. http://proxy:8080),
mirroring the existing socks5_proxy= convention.

Implemented as HttpConnectWrapper in kafka/http_connect_wrapper.py —
a non-blocking state machine (DISCONNECTED → CONNECTING → SENDING →
READING → COMPLETE) that satisfies the same three-method contract as
Socks5Wrapper: use_remote_lookup, socket, connect_ex.

Broker hostnames are always forwarded unresolved so the proxy handles
DNS from inside the network. Proxy authentication and TLS-to-proxy
(https://) are deferred to a follow-up.

Also adds kafka/net/__init__.py to fix a packaging bug where setuptools
(namespaces=false) would not include kafka.net as an installable package.
@ZivBleich ZivBleich force-pushed the ZivBleich/http-connect-proxy branch from 3023bbf to baa42aa Compare May 25, 2026 08:45
@ZivBleich ZivBleich marked this pull request as ready for review May 25, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant