### Question:
CorsUtil { public static String defaultOrigin(HttpServerExchange exchange) { String host = NetworkUtils.formatPossibleIpv6Address(exchange.getHostName()); String protocol = exchange.getRequestScheme(); int port = exchange.getHostPort(); StringBuilder allowedOrigin = new StringBuilder(256); allowedOrigin.append(protocol).append(": if (!isDefaultPort(port, protocol)) { allowedOrigin.append(':').append(port); } return allowedOrigin.toString(); }  static boolean isCoreRequest(HeaderMap headers); static String matchOrigin(HttpServerExchange exchange, Collection<String> allowedOrigins); static String defaultOrigin(HttpServerExchange exchange); static String sanitizeDefaultPort(String url); static boolean isPreflightedRequest(HttpServerExchange exchange);  }### Answer:
@Test public void testDefaultOrigin() { HeaderMap headerMap = new HeaderMap(); headerMap.add(HOST, "localhost:80"); HttpServerExchange exchange = new HttpServerExchange(null, headerMap, new HeaderMap(), 10); exchange.setRequestScheme("http"); assertThat(CorsUtil.defaultOrigin(exchange), is("http: headerMap.clear(); headerMap.add(HOST, "www.example.com:8080"); assertThat(CorsUtil.defaultOrigin(exchange), is("http: headerMap.clear(); headerMap.add(HOST, "www.example.com:443"); exchange.setRequestScheme("https"); assertThat(CorsUtil.defaultOrigin(exchange), is("https: headerMap.clear(); exchange.setRequestScheme("http"); headerMap.add(HOST, "[::1]:80"); assertThat(CorsUtil.defaultOrigin(exchange), is("http: }