Skip to content

HttpClient does not support IPv6 with scope ID on Mac or Linux #17187

@mikeharder

Description

@mikeharder

Repro Steps

  1. Start an HTTP server on an IPv6 address with a scope ID. An example is the link-local address provided by running ifconfig.
  2. Run curl to verify the server is working.
    2a. On Mac, I needed to wrap the IPv6 address with brackets, and escape the % as %25. For example: curl http://[fe80::blah%25en0]:1234/.
    2b. On Linux, I needed to not wrap with brackets, and not escape the %. For example: curl http://fe80::blah%eth0:1234/.
  3. Call new HttpClient().GetAsync() using the same URL you passed to curl.

Expected
HttpClient works the same as curl itself.

Actual
HttpClient fails with an error like System.Net.Http.CurlException: Couldn't connect to server or System.UriFormatException: Invalid URI.

Notes
I tested many combinations of with/without brackets and with/without % encoded as %25, but none of them worked.

HttpClient on Windows does work correctly with IPv6 scope ID (tested with brackets and without encoding %).

Documentation for IPv6 scope ID support in Windows: https://msdn.microsoft.com/en-us/library/windows/desktop/aa385325(v=vs.85).aspx

Curl Versions
Mac

curl 7.37.1 (x86_64-apple-darwin14.0) libcurl/7.37.1 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz

Linux

curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions