@Test
    void requireThatMissingOrBlankHostHeaderFailsWith400() throws Exception {
        // Jetty requires that Host header is present and non-blank.
        var driver = JettyTestDriver.newInstance(new EchoRequestHandler());
        int listenPort = driver.server().getListenPort();

        try (var client = HttpClients.custom()
                .addRequestInterceptorLast((req, entityDetails, httpCtx) -> req.removeHeaders(HttpHeaders.HOST))
                .build()) {
            var req = new HttpGet("http://localhost:" + listenPort + "/");
            client.execute(req, (HttpClientResponseHandler<Void>) response -> {
                assertEquals(BAD_REQUEST, response.getCode());
                var content = EntityUtils.toString(response.getEntity());
                assertTrue(content.contains("HTTP ERROR 400 No Host"), content);
                return null;
            });
        }

        try (var client = HttpClients.custom()
                .addRequestInterceptorLast((req, entityDetails, httpCtx) -> req.setHeader(HttpHeaders.HOST, ""))
                .build()) {
            var req = new HttpGet("http://localhost:" + listenPort + "/");
            client.execute(req, (HttpClientResponseHandler<Void>) response -> {
                assertEquals(BAD_REQUEST, response.getCode());
                var content = EntityUtils.toString(response.getEntity());
                assertTrue(content.contains("HTTP ERROR 400 Blank Host"), content);
                return null;
            });

        }
        assertTrue(driver.close());
    }
@author Oyvind Bakksjo
@author Simon Thoresen Hult
@author bjorncs
container-core/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java