cpp-httplib icon indicating copy to clipboard operation
cpp-httplib copied to clipboard

Handling for URLs containing IPv6 addresses broken

Open gjasny opened this issue 4 years ago • 4 comments

Hello,

I noticed that the library cannot handle URLs like http://[::1]/ because it does not consider the []-escaped IPv6 addresses. It's a problem in both: the Client constructors as well as the Host:-HTTP header.

Thanks, Gregor

gjasny avatar Jun 30 '21 12:06 gjasny

@gjasny, thanks for the report. I right now don't have time to work on it. If you have time, could you send me a pull request with a unit test case? Thanks!

yhirose avatar Jul 07 '21 13:07 yhirose

Hello,

thanks for taking care. Unfortunately the Host header still looks wrong:

GET /cache/8e193hu1ntu7bvd6ohhsrncr94hibhn8s HTTP/1.1
Accept: */*
Host: ::1:8080
User-Agent: ccache/master.b7e6280e

Maybe you could use a dedicated URL class for parsing like: CxxUrl?

Thanks, Gregor

gjasny avatar Jul 15 '21 06:07 gjasny

ipv6 must have [ ] in url or header

lifw555 avatar Nov 24 '22 09:11 lifw555

Open this issue again. A pull request is welcome!

https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers https://serverfault.com/questions/1026466/ipv6-address-text-notation-with-prefix-inside-or-outside-square-brackets

yhirose avatar Jan 10 '23 22:01 yhirose

https://github.com/yhirose/cpp-httplib/blob/9e4f93d87e744c9038554d19f3837980959093e2/test/test.cc#L1597

yhirose avatar Jun 17 '24 15:06 yhirose