8000 properly handle ipv6 hosts · Issue #714 · googleapis/python-api-core · GitHub
[go: up one dir, main page]

Skip to content
properly handle ipv6 hosts #714
Open
@vchudnov-g

Description

@vchudnov-g

We need to ensure our code works with IPv6. One aspect I noticed is the following:

We have core that defaults the host to use HTTPS. It looks like this:

        if ":" not in host:
            host += ":443"  # pragma: NO COVER

However, IPv6 addresses are allowed in URLs, enclosed in brackets (ref), and IPv6 addresses use colons as separators. The code as written would never default to HTTPS for IPv6. So we should have more robust logic to allow for that.


Separately, the code above is preceded by a regex to look for the URL schema, but it only recognizes HTTP and HTTPS. I suggest we be more general and look for arbitrary schema by examining the host name until the leading colon. This is probably a pedantic point, but there are unregistered schemes being used, and more schemes could conceivably be registered. On principle, we shouldn't be more restrictive than we need to be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0