Omit the IPv6 zone from the `Host` header

KL
1d ago
+38-4

Summary

Closes #676.

A URL with an IPv6 zone, such as http://[fe80::1%en0]/, sent the zone in the Host header:

Host: [fe80::1%en0]

The zone names a network interface on the client. It means nothing to the server, and #676 reports that Apache and lighttpd reject the request. RFC 9844, section 6 says zone identifiers "must not be sent on the wire", and curl strips it too.

The Host header is now [fe80::1], both for a new Request and when a redirect changes the origin. An explicit Host header is left alone.

URL.netloc and URL.host keep the zone. The connection still needs it to pick the interface, and cookies stay scoped to it.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Session: pi --session 01a20ced-af54-7647-a636-b3d9c9458448