Skip to content

IPv6 in URL is missing brackets in proxy CONNECT request #3841

Closed as not planned
@shnavid-zz

Description

Long story short

Requests to a URL containing an IPv6 address while using a proxy results in a malformed CONNECT request.

Expected behaviour

The request should make it through the proxy and reach the IPv6 server.

Actual behaviour

The proxy is returning an error (400, Bad request).

Steps to reproduce

async with aiohttp.request(
  'get',
  'https://[2320:10a:c081:56::363]:443/testing.txt',
   proxy="http://whatever:8080",
 ) as response:
     print(response)

tcpdump shows (notice the missing brackets):

CONNECT 2320:10a:c081:56::363:443 HTTP/1.1
Host: [2320:10a:c081:56::363]
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Python/3.6 aiohttp/3.5.4

I patched https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client_reqrep.py#L543 to add the brackets and confirmed that the request is going through.

Your environment

aiohttp/3.5.4 (client)
CentOS 7.5

Metadata

Assignees

No one assigned

    Labels

    Staleneeds-infoIssue is lacking sufficient information and will be closed if not provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions