public static String defaultOrigin(HttpServerExchange exchange) {
        String host = NetworkUtils.formatPossibleIpv6Address(exchange.getHostName());
        String protocol = exchange.getRequestScheme();
        int port = exchange.getHostPort();
        //This browser set header should not need IPv6 escaping
        StringBuilder allowedOrigin = new StringBuilder(256);
        allowedOrigin.append(protocol).append("://").append(host);
        if (!isDefaultPort(port, protocol)) {
            allowedOrigin.append(':').append(port);
        }
        return allowedOrigin.toString();
    }
@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://localhost"));
        headerMap.clear();
        headerMap.add(HOST, "www.example.com:7080");
        assertThat(CorsUtil.defaultOrigin(exchange), is("http://www.example.com:7080"));
        headerMap.clear();
        headerMap.add(HOST, "www.example.com:443");
        exchange.setRequestScheme("https");
        assertThat(CorsUtil.defaultOrigin(exchange), is("https://www.example.com"));
        headerMap.clear();
        exchange.setRequestScheme("http");
        headerMap.add(HOST, "[::1]:80");
        assertThat(CorsUtil.defaultOrigin(exchange), is("http://[::1]"));
    }