Description
Custom transport classes might want to support alternate schemes in addition to "http" and "https".
Issue #931 includes a couple of examples here...
- Use of a
test:scheme in unit tests for session handling. - Use of
http+thing:custom schemes that enable additional behaviours at the transport level.
The question is how would we best want to support this. One thing that might be sensible here is to change the Transport API slightly, so that the url signature is Tuple[bytes, bytes, Optional[int], bytes] instead of the current Tuple[bytes, bytes, int, bytes].
We would then pass only any explicitly included port in the URL, and leave any protocol->port mapping to the responsibility of the transport class. The AsyncConnectionPool and SyncConnectionPool classes would enforce scheme=[b'http'|b'https'], but alternate transport classes could provide other behaviour.
A first step here would to to review where in the httpx codebase we're currently accessing the URL port.
Activity
yeraydiazdiaz commentedon May 16, 2020
I think we should scope this issue a bit.
If that's the case then we can change how port is derived from the scheme in the
URLmodel.Or,
dispatch_for_urldecides which transport to use.Supporting arbitrary schemes introduces quite a few questions:
lovelydinosaur commentedon May 17, 2020
To rephrase this slightly, it's not exactly about "supporting alternate schemes" so much as "Enforcing http/https and determining default port mappings should be the responsibility of the transport layer."
Changes would be:
Tuple[bytes, bytes, Optional[int], bytes].URL.portshould return anOptional[int]instead ofint. Don't return a default-port-for-the-scheme if there's no port in the URL.https://example.com:443/andhttps://example.com/to be treated as the same origin for those purposes.Client.dispatcher_for_urlwould need a bit of rejigging ifURL.portreturned anOptional[int].florimondmanca commentedon May 21, 2020
Didn't realize initially that there was already an initial PR about this in HTTPCore - encode/httpcore#92
lovelydinosaur commentedon May 21, 2020
Okay so #967 and
httpcore 0.9address the only bits of this that we need for 0.13, so I'm going to milestone this as 1.0 now.lovelydinosaur commentedon Jul 27, 2020
Closing this issue in favour of #1059