File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -9213,7 +9213,7 @@ inline Client::Client(const std::string &scheme_host_port,
92139213 const std::string &client_cert_path,
92149214 const std::string &client_key_path) {
92159215 const static std::regex re (
9216- R"( (?:([a-z]+):\/\/)?(?:\[([\d:]+)\]|([^:/?#]+))(?::(\d+))?)" );
9216+ R"( (?:([a-z]+):\/\/)?(?:\[([a-fA-F \d:]+)\]|([^:/?#]+))(?::(\d+))?)" );
92179217
92189218 std::smatch m;
92199219 if (std::regex_match (scheme_host_port, m, re)) {
@@ -9250,6 +9250,8 @@ inline Client::Client(const std::string &scheme_host_port,
92509250 client_key_path);
92519251 }
92529252 } else {
9253+ // NOTE: Update TEST(UniversalClientImplTest, Ipv6LiteralAddress)
9254+ // if port param below changes.
92539255 cli_ = detail::make_unique<ClientImpl>(scheme_host_port, 80 ,
92549256 client_cert_path, client_key_path);
92559257 }
Original file line number Diff line number Diff line change @@ -7373,3 +7373,18 @@ TEST(PathParamsTest, SequenceOfParams) {
73737373
73747374 EXPECT_EQ (request.path_params , expected_params);
73757375}
7376+
7377+ TEST (UniversalClientImplTest, Ipv6LiteralAddress) {
7378+ // If ipv6 regex working, regex match codepath is taken.
7379+ // else port will default to 80 in Client impl
7380+ int clientImplMagicPort = 80 ;
7381+ int port = 4321 ;
7382+ // above ports must be different to avoid false negative
7383+ EXPECT_NE (clientImplMagicPort, port);
7384+
7385+ std::string ipV6TestURL = " http://[ff06::c3]" ;
7386+
7387+ Client cli (ipV6TestURL + " :" + std::to_string (port), CLIENT_CERT_FILE,
7388+ CLIENT_PRIVATE_KEY_FILE);
7389+ EXPECT_EQ (cli.port (), port);
7390+ }
You can’t perform that action at this time.
0 commit comments