-
Notifications
You must be signed in to change notification settings - Fork 107
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
Advanced connection options. #88
Comments
For reference, this is what you can do with |
@hynek - Gotcha. The DNS caching isn't something I think we need to introduce, since it adds less reliable side-effects. Perhaps it's a feasible feature at some point, but let's treat it as out of scope for purposes here. Out of the other stuff:
|
I personally need to be able to force IPv4 by setting the socket family to That could be abstracted away of course to be more use friendly. |
I'm planning to look at adding source_address support to the ConnectionPool objects. @hynek - I believe that choosing an address family would be functionally equivalent to specifying a wildcard source address in that family; that is, using |
Adding source address support is surprisingly complicated, unfortunately. Getting the address down to the various In the sync backend, the code (currently) assumes IPv4 when opening a socket. If this restriction is kept, the only change would be to optionally call In the trio backend, The asyncio backend looks like the easiest one; |
Hey @bwelling, thanks for looking into this. We should think about how we'd like to expose this at the top
That makes sense, I think we should have both a
I don't think we need to keep that restriction, seems like an oversight on our part since we tend to focus on the async side of things. I see no reason we can't use the family and/or source address in the
I'm not familiar with Trio but I think it's probably ok to lose the happy eyeballs feature as a tradeoff for ensuring the local address constraint is met. I'm curious why Trio does not support setting local address though.
Yep, seems straightforward 🙂 BTW, there's not a lot of documentation in terms of contributing to httpcore, but generally we work on the async side and run |
I believe so. The top layer could probably convert the family into a wildcard source address, if we wanted to simplify the parameters passed to the lower layers. Similarly, the top layer could convert an address string into an address tuple.
Using
There's a comment in the Trio code about supporting potentially local address in the future, so I don't think it's intentional. Getting Trio to work will not be trivial, as the current code passes the hostname to trio, which does the DNS resolution. This would need to be changed to do the DNS resolution outside of trio, so that the calling code has an address, and can open a socket in the correct address family. That is, more or less replicate a lot of the
Yeah. I noticed that after making (small, fortunately) changes to the sync side and having |
So, we don't necessarily need to have all options supported on all backends. I think the first point here is just determining what additional arguments we think we'd want to accept. That'd mean:
In the sync casePass
In the asyncio casePass In the trio caseHave the backend raise an error if either argument is used, indicating that they're not currently supported. Open an issue or draft a PR with the trio project to see about getting them included in the high-level API. Have I got that about right? Does that all seem reasonable? |
Wait, httpx disables IPv6 by default? Changing that is breaking but lucky you're still in 0ver yolo land. :) So yeah, |
Appears to be an oversight in the sync case, yup... httpcore/httpcore/_backends/sync.py Line 133 in 221754b
Not for asyncio or trio. |
Resolved in #97 |
Ah yeah, supporting source interfaces in There are a few boring API details to figure out but it shouldn't be too hard to add. |
Closing this off, since we haz these now. |
Prompted by a comment from @hynek
We ought to add more
__init__
controls toAsyncConnectionPool(...)
andSyncConnectionPool(...)
for advanced connection options, including...It'd be useful to do a comprehensive review of...
Compare against controls available in
urllib3
,aiohttp
.The text was updated successfully, but these errors were encountered: