MCPcopy Create free account
hub / github.com/apache/trafficserver / getPort

Method getPort

src/traffic_cache_tool/CacheDefs.cc:98–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98int
99URLparser::getPort(std::string &fullURL, int &port_ptr, int &port_len)
100{
101 url_matcher matcher;
102 int n_port = -1;
103 int u_pos = -1;
104
105 if (fullURL.find("https") == 0) {
106 u_pos = 8;
107 n_port = 443;
108 } else if (fullURL.find("http") == 0) {
109 u_pos = 7;
110 n_port = 80;
111 }
112 if (u_pos != -1) {
113 fullURL.insert(u_pos, ":@");
114 swoc::TextView url(fullURL.data(), static_cast<int>(fullURL.size()));
115
116 url += 9;
117
118 swoc::TextView hostPort = url.take_prefix_at(':');
119 if (!hostPort.empty()) // i.e. port is present
120 {
121 swoc::TextView port = url.take_prefix_at('/');
122 if (port.empty()) { // i.e. backslash is not present, then the rest of the url must be just port
123 port = url;
124 }
125 if (matcher.portmatch(port.data(), port.size())) {
126 swoc::TextView text;
127 n_port = svtoi(port, &text);
128 if (text == port) {
129 port_ptr = fullURL.find(':', 9);
130 port_len = port.size();
131 return n_port;
132 }
133 }
134 }
135 return n_port;
136 } else {
137 std::cout << "No scheme provided for: " << fullURL << std::endl;
138 return -1;
139 }
140}
141
142uint32_t
143Doc::prefix_len()

Callers 1

loadURLsMethod · 0.45

Calls 8

svtoiFunction · 0.85
take_prefix_atMethod · 0.80
portmatchMethod · 0.80
findMethod · 0.45
insertMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected