-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add possibility to specify IPv4 or IPv6? #1691
Comments
That feature is handled way way down in the standard library, not even exposed by httplib, so isn't something we can easily provide access to. It's also phenomenally special-case, which makes us reluctant to add it to the library. However, if you really need to you can handle it yourself: import socket
addrs = socket.getaddrinfo('www.google.com')
ipv4_addrs = [addr[4][0] for addr in addrs if addr[0] == socket.AF_INET]
ipv6_addrs = [addr[4][0] for addr in addrs if addr[0] == socket.AF_INET6] At this point you can build your URL using the literal IP address rather than the hostname, remembering to correctly set the |
I switched a dependency to The previous package (restkit) use a solution similar to
I think that it can be solved by subclassing HTTPConnection and by overriding its short |
So the way I consider the question is this: if we subclass Firstly, note that the subclassing will happen in urllib3, not here. urllib3 will be happy to take this I'm sure. Once that subclassing is done, Requests would need a way to provide an API to it. Interestingly, that API would probably end up being a That will be easier if you get your patch into urllib3, so I recommend you start there first. |
I think a 'specify IP type' TA would be a good addition. It would be nice not to have to monkeypatch urllib3 to do it though. =) |
Agreed. |
Ran into needing this. I enabled ipv6 on my service so people with out ipv4 could connect. But i use the ipv4 addresses for something some users who have both find them selves a little confussed. would be great to add pinning to ip type |
I am not sure if the work around works when doing https? |
Yeah, HTTPS is a problem here. Having a toolbelt adaptor would help. |
Hi there, it's nearly 7 years later. Is there any easy, user friendly way to specify the IP version that requests should use? |
No |
here's a convenient requests wrapper by Alexander Schlarb: https://gitlab.com/-/snippets/1900824 |
I noticed that request by default uses IPv6 if a host is capable of it. However, requests seems to lack the ability to force it to use either IPv6 or IPv4. Would it be possible to add an option that allows one to manually select the protocol?
The text was updated successfully, but these errors were encountered: