-
-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the specifying of which system IP address to use for client connections. #755
Comments
Thanks, that's a really interesting request. I think we're likely at a stage in the project where we'd probably push back on new API unless we consider it absolutely clear-cut must have functionality, and that some things that don't fall into that category could go into a maybe later, but let's get more real-world feedback first, so my initial reaction would probably be to put this into the "interesting, maybe later" pile... For a bit of context, what's the motivation / use-case here? |
|
I can find it in |
Closed as "out of scope" for requests, psf/requests#394 but available in the toolbelt... https://toolbelt.readthedocs.io/en/latest/adapters.html#sourceaddressadapter |
I assumed for requests itself. But, yeah. Still available in semi-official capacity. Edit: And the rest were from code searches, though they're not all spelled the same way |
The use case I have run into many times now is the need to simulate a pool of users, sourcing from unique IP addresses, for simulating users. This is not possible with requests and has been requested as an enhancement many times. Today I find users spawning off multiple containers to accomplish this vs. using a single machine, with multiple secondary IP addresses bound to the NIC, to accomplish this. To add more color to the use case: testing a web proxy, FW, wan optimizer, and network traffic probes, ...etc, whereby a single IP requesting many webpages. |
I was just looking for this functionality in httpx, for a use case of sending DoH (DNS over HTTPS) requests, from dnspython. Currently, dnspython uses requests to send queries, and requests_toolbelt.adapters.source.SourceAddressAdapter (when necessary) to set the source address, but since DoH is supposed to use HTTP/2, it would be nice to use httpx instead. |
I'm going to currently close this off as out of scope. We might be able to consider a nicely done PR to |
Since there is no proper documentation for this, here is how to use local address:
|
To answer earlier question: how to do it with requests: https://stackoverflow.com/questions/48776564/python-and-c-sharing-the-same-memory-resources |
I'm trying to get an async version working:
... but getting an error:
|
You need to be using |
Thanks!
|
ok gottit!
Thanks @tomchristie for shaking it loose |
Just a note that trying a different target URL I ran into |
Allow the specifying of which system IP address to use for client connections. If you look at http.client.HTTPConnection, it allows you pass a source address:
class http.client.HTTPConnection(host, port=None, [timeout, ]source_address=None, blocksize=8192)
https://docs.python.org/3/library/http.client.html
The text was updated successfully, but these errors were encountered: