feat: Add HTTP CONNECT proxy support (http_connect_proxy=)#2990
Open
ZivBleich wants to merge 1 commit into
Open
feat: Add HTTP CONNECT proxy support (http_connect_proxy=)#2990ZivBleich wants to merge 1 commit into
ZivBleich wants to merge 1 commit into
Conversation
ZivBleich
added a commit
to ZivBleich/kafka-python
that referenced
this pull request
May 25, 2026
0258773 to
3023bbf
Compare
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.
3023bbf to
baa42aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
http_connect_proxy=toKafkaConsumer,KafkaProducer, andKafkaAdminClient.HttpConnectWrapperinkafka/http_connect_wrapper.pyimplements this as a non-blocking state machine satisfying the same three-method contract asSocks5Wrapper:use_remote_lookup,socket,connect_ex.Also adds
kafka/net/__init__.pyto fix a packaging bug:pyproject.tomlsetsnamespaces = false, so setuptools only includes subdirectories with__init__.py. Without it,kafka.netis silently excluded from installed wheels.Tests: