@Override
    public String reconstructURI() {
        // If this instance is immutable, then lazy-cache reconstructing the uri.
        if (immutable) {
            if (reconstructedUri == null) {
                reconstructedUri = _reconstructURI();
            }
            return reconstructedUri;
        } else {
            return _reconstructURI();
        }
    }
@Test
    void testReconstructURI() {
        HttpQueryParams queryParams = new HttpQueryParams();
        queryParams.add("flag", "5");
        Headers headers = new Headers();
        headers.add("Host", "blah.netflix.com");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("https://blah.netflix.com:7002/some/where?flag=5", request.reconstructURI());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("X-Forwarded-Host", "place.netflix.com");
        headers.add("X-Forwarded-Port", "80");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "http",
                7002,
                "localhost");
        assertEquals("http://place.netflix.com/some/where", request.reconstructURI());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("X-Forwarded-Host", "place.netflix.com");
        headers.add("X-Forwarded-Proto", "https");
        headers.add("X-Forwarded-Port", "443");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "http",
                7002,
                "localhost");
        assertEquals("https://place.netflix.com/some/where", request.reconstructURI());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "http",
                7002,
                "localhost");
        assertEquals("http://localhost:7002/some/where", request.reconstructURI());

        queryParams = new HttpQueryParams();
        queryParams.add("flag", "5");
        queryParams.add("flag B", "9");
        headers = new Headers();
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some%20where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("https://localhost:7002/some%20where?flag=5&flag+B=9", request.reconstructURI());
    }