| 260 | } |
| 261 | |
| 262 | bool TryGetSchemeHostAndPort(const TStringBuf url, TStringBuf& scheme, TStringBuf& host, ui16& port) { |
| 263 | const size_t schemeSize = GetSchemePrefixSize(url); |
| 264 | if (schemeSize != 0) { |
| 265 | scheme = url.Head(schemeSize); |
| 266 | } |
| 267 | |
| 268 | TStringBuf portStr; |
| 269 | TStringBuf hostAndPort = GetHostAndPort(url.Tail(schemeSize)); |
| 270 | if (hostAndPort && hostAndPort.back() != ']' && hostAndPort.TryRSplit(':', host, portStr)) { |
| 271 | // URL has port |
| 272 | if (!TryFromString(portStr, port)) { |
| 273 | return false; |
| 274 | } |
| 275 | } else { |
| 276 | host = hostAndPort; |
| 277 | if (scheme == TStringBuf("https://")) { |
| 278 | port = 443; |
| 279 | } else if (scheme == TStringBuf("http://")) { |
| 280 | port = 80; |
| 281 | } |
| 282 | } |
| 283 | return true; |
| 284 | } |
| 285 | |
| 286 | void GetSchemeHostAndPort(const TStringBuf url, TStringBuf& scheme, TStringBuf& host, ui16& port) { |
| 287 | bool isOk = TryGetSchemeHostAndPort(url, scheme, host, port); |
no test coverage detected