As in https://github.com/encode/httpx/issues/755, it would be useful to be able to specify the source address. I’m willing to work on a PR, if there’s any chance that something like this would be accepted.
I’m not sure exactly what the implementation in httpcore would look like, but it would likely involve setting an option on the SyncConnectionPool object, which passed it to SyncHTTPConnection, and then down to open_tcp_stream() (the async case is similar). The caller could pass in either the address either as a string, or a socket address tuple; if it was a string, it would be converted into a socket address. open_tcp_stream() would, if the source address was defined, call bind() on the socket.
Allowing this to be specified per-request would be more complicated, as that requires that the connection pool track connections by both origin and source address.