RequestParser { int requestPort(String host, String scheme, HttpServerExchange exchange) { if (host != null) { int colonIndex; if (Strings.startsWith(host, '[')) { colonIndex = host.indexOf(':', host.indexOf(']')); } else { colonIndex = host.indexOf(':'); } if (colonIndex > 0 && colonIndex + 1 < host.length()) { return Integer.parseInt(host.substring(colonIndex + 1)); } if ("https".equals(scheme)) return 443; if ("http".equals(scheme)) return 80; } return exchange.getDestinationAddress().getPort(); }  void parse(RequestImpl request, HttpServerExchange exchange, ActionLog actionLog); final ClientIPParser clientIPParser; public boolean logSiteHeaders; }
@Test void requestPort() { assertThat(parser.requestPort("127.0.0.1", "https", null)).isEqualTo(443); assertThat(parser.requestPort("127.0.0.1:8080", "http", null)).isEqualTo(8080); assertThat(parser.requestPort("[::1]:8080", "http", null)).isEqualTo(8080); }