Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
web::uri::port()says "Returns -1 if no port is specified."This is the initial value of a default-constructed
web::uriorweb::uri_builder.However,
web::uri::is_port_default()tests forport() == 0.Parsing a URI string e.g. using the
web::uriconstructor, results in the port being set to 0 if the URI string doesn't specify a port.This means that:
web::uri(U("http://example.com/")) != web::uri_builder().set_scheme(U("http")).set_host(U("example.com")).to_uri()That was surprising to me.
Are 'port unspecified' (-1) and 'port default' really supposed to be distinct?
In other words, should a user of
web::uri_builderhave to explicitly set default port?web::uri(U("http://example.com/")) == web::uri_builder().set_scheme(U("http")).set_host(U("example.com")).set_port(0).to_uri()If so, since the fact that 0 indicates default is not documented, would it be worth adding
uri_builder::set_default_port()?