relayTargetOf function
CONNECT host:port from the request line, else the Host header — the relay target every accepted inbound is bound through. Public and socket-free so the unit suite drives the parse paths directly.
Implementation
(String, int) relayTargetOf(String requestLine, String head) {
if (requestLine.startsWith('CONNECT')) {
// CONNECT carries no scheme — the tunnel target is https by
// convention; an explicit port in the authority wins.
return _splitAuthority(
_connectAuthority(requestLine),
requestLine,
fallbackPort: 443,
);
}
final absolute = _absoluteFormTarget(requestLine);
if (absolute != null) return absolute;
// Plain origin-form fell through to the Host header: http's default.
return _splitAuthority(
_hostHeaderAuthority(head),
requestLine,
fallbackPort: 80,
);
}