Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Rework host/hostname/authority implementation. #1561
…ame`. u = URI("http://[::1]/bar") p u.hostname #=> "::1" p u.host #=> "[::1]"
With IPv6, any time we have a string which represents an authority, as defined by RFC7540, the address must be contained within square brackets, e.g.: "[2020::1985]:443". Representations from the `host` header and `authority` pseudo-header must conform to this format. Some headers, notably `x-forwarded-for` and `x-forwarded-host` do not format the authority correctly. So we introduce a private method `wrap_ipv6` which uses a heuristic to detect these situations and fix the formatting. Additionally, we introduce some new assertions in `Rack::Lint` to ensure SREVER_NAME and HTTP_HOST match the formatting requirements.