@Override
    public String getOriginalHost() {
        try {
            if (originalHost == null) {
                originalHost = getOriginalHost(getHeaders(), getServerName());
            }
            return originalHost;
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
@Test
    void testGetOriginalHost() {
        HttpQueryParams queryParams = new HttpQueryParams();
        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("blah.netflix.com", request.getOriginalHost());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("Host", "0.0.0.1");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("0.0.0.1", request.getOriginalHost());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("Host", "0.0.0.1:2");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("0.0.0.1", request.getOriginalHost());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("Host", "[::2]");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("[::2]", request.getOriginalHost());

        queryParams = new HttpQueryParams();
        headers = new Headers();
        headers.add("Host", "[::2]:3");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("[::2]", request.getOriginalHost());

        headers = new Headers();
        headers.add("Host", "blah.netflix.com");
        headers.add("X-Forwarded-Host", "foo.netflix.com");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("foo.netflix.com", request.getOriginalHost());

        headers = new Headers();
        headers.add("X-Forwarded-Host", "foo.netflix.com");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("foo.netflix.com", request.getOriginalHost());

        headers = new Headers();
        headers.add("Host", "blah.netflix.com:8080");
        request = new HttpRequestMessageImpl(
                new SessionContext(),
                "HTTP/1.1",
                "POST",
                "/some/where",
                queryParams,
                headers,
                "192.168.0.2",
                "https",
                7002,
                "localhost");
        assertEquals("blah.netflix.com", request.getOriginalHost());
    }