use of io.undertow.server.handlers.error.SimpleErrorPageHandler in project undertow by undertow-io.
the class ComplexSSLTestCase method complexSSLTestCase.
@Test
public void complexSSLTestCase() throws IOException, GeneralSecurityException, URISyntaxException, InterruptedException {
final PathHandler pathHandler = new PathHandler();
Path rootPath = Paths.get(FileHandlerTestCase.class.getResource("page.html").toURI()).getParent();
final NameVirtualHostHandler virtualHostHandler = new NameVirtualHostHandler();
HttpHandler root = virtualHostHandler;
root = new SimpleErrorPageHandler(root);
root = new CanonicalPathHandler(root);
virtualHostHandler.addHost("default-host", pathHandler);
virtualHostHandler.setDefaultHandler(pathHandler);
pathHandler.addPrefixPath("/", new ResourceHandler(new PathResourceManager(rootPath, 10485760)).setDirectoryListingEnabled(true));
DefaultServer.setRootHandler(root);
DefaultServer.startSSLServer();
TestHttpClient client = new TestHttpClient();
client.setSSLContext(DefaultServer.getClientSSLContext());
try {
//get file list, this works
HttpGet getFileList = new HttpGet(DefaultServer.getDefaultServerSSLAddress());
HttpResponse resultList = client.execute(getFileList);
Assert.assertEquals(StatusCodes.OK, resultList.getStatusLine().getStatusCode());
String responseList = HttpClientUtils.readResponse(resultList);
Assert.assertTrue(responseList, responseList.contains("page.html"));
Header[] headersList = resultList.getHeaders("Content-Type");
Assert.assertEquals("text/html; charset=UTF-8", headersList[0].getValue());
//get file itself, breaks
HttpGet getFile = new HttpGet(DefaultServer.getDefaultServerSSLAddress() + "/page.html");
HttpResponse result = client.execute(getFile);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
String response = HttpClientUtils.readResponse(result);
Header[] headers = result.getHeaders("Content-Type");
Assert.assertEquals("text/html", headers[0].getValue());
Assert.assertTrue(response, response.contains("A web page"));
} finally {
client.getConnectionManager().shutdown();
DefaultServer.stopSSLServer();
}
}
use of io.undertow.server.handlers.error.SimpleErrorPageHandler in project wildfly by wildfly.
the class Server method start.
@Override
public void start(StartContext startContext) throws StartException {
root = virtualHostHandler;
root = new SimpleErrorPageHandler(root);
root = new CanonicalPathHandler(root);
root = new DefaultHostHandler(root);
UndertowLogger.ROOT_LOGGER.startedServer(name);
undertowService.getValue().registerServer(this);
}
Aggregations