MCPcopy Create free account
hub / github.com/apache/brpc / ParseHttpServerAddress

Function ParseHttpServerAddress

src/brpc/policy/http_rpc_protocol.cpp:1747–1773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1745}
1746
1747bool ParseHttpServerAddress(butil::EndPoint* point, const char* server_addr_and_port) {
1748 std::string scheme;
1749 std::string host;
1750 int port = -1;
1751 if (ParseURL(server_addr_and_port, &scheme, &host, &port) != 0) {
1752 LOG(ERROR) << "Invalid address=`" << server_addr_and_port << '\'';
1753 return false;
1754 }
1755 if (scheme.empty() || scheme == "http") {
1756 if (port < 0) {
1757 port = 80;
1758 }
1759 } else if (scheme == "https") {
1760 if (port < 0) {
1761 port = 443;
1762 }
1763 } else {
1764 LOG(ERROR) << "Invalid scheme=`" << scheme << '\'';
1765 return false;
1766 }
1767 if (str2endpoint(host.c_str(), port, point) != 0 &&
1768 hostname2endpoint(host.c_str(), port, point) != 0) {
1769 LOG(ERROR) << "Invalid host=" << host << " port=" << port;
1770 return false;
1771 }
1772 return true;
1773}
1774
1775const std::string& GetHttpMethodName(
1776 const google::protobuf::MethodDescriptor*,

Callers 2

TEST_FFunction · 0.85
TESTFunction · 0.85

Calls 5

ParseURLFunction · 0.85
str2endpointFunction · 0.85
hostname2endpointFunction · 0.85
emptyMethod · 0.45
c_strMethod · 0.45

Tested by 2

TEST_FFunction · 0.68
TESTFunction · 0.68