| 281 | } |
| 282 | |
| 283 | private static int findPortStartColon(String authority, int hostStart) { |
| 284 | for (int i = authority.length() - 1; i >= hostStart; --i) { |
| 285 | char c = authority.charAt(i); |
| 286 | if (c == ':') { |
| 287 | return i; |
| 288 | } |
| 289 | if (c == ']') { |
| 290 | // Hit the end of IP-literal. Any further colon is inside it and couldn't indicate a port. |
| 291 | break; |
| 292 | } |
| 293 | if (!digitChars.get(c)) { |
| 294 | // Found a non-digit, non-colon, non-bracket. |
| 295 | // This means there is no valid port (e.g. host is "example.com") |
| 296 | break; |
| 297 | } |
| 298 | } |
| 299 | return -1; |
| 300 | } |
| 301 | |
| 302 | // Checks a raw path for validity and parses it into segments. Let 'out' be null to just validate. |
| 303 | private static void parseAssumedUtf8PathIntoSegments( |