Skip to content

client use ipv6 error #2233

@lifw555

Description

@lifw555
inline Client::Client(const std::string &scheme_host_port,
                      const std::string &client_cert_path,
                      const std::string &client_key_path) {
.......

    auto host = m[2].str();
    if (host.empty()) { host = m[3].str(); }

.......

If the client initiates an IPv6 request, the IPv6 address in the host field of the request header is not used [], which can cause the server to receive an error in parsing the request header.

Add the following code to fix this bug

inline Client::Client(const std::string &scheme_host_port,
                      const std::string &client_cert_path,
                      const std::string &client_key_path) {
.......

    auto host = m[2].str();
    if (host.empty()) { host = m[3].str(); }
    if (host.find(':') != std::string::npos) { host = "[" + host + "]"; }   // this code 
.......

Hope it's useful

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions