Java Code Examples for io.undertow.server.handlers.BlockingHandler#setRootHandler()
The following examples show how to use
io.undertow.server.handlers.BlockingHandler#setRootHandler() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaxRequestSizeTestCase.java From quarkus-http with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() { final BlockingHandler blockingHandler = new BlockingHandler(); DefaultServer.setRootHandler(blockingHandler); blockingHandler.setRootHandler(new HttpHandler() { @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final OutputStream outputStream = exchange.getOutputStream(); final InputStream inputStream = exchange.getInputStream(); String m = HttpClientUtils.readResponse(inputStream); Assert.assertEquals(A_MESSAGE, m); inputStream.close(); outputStream.close(); } }); }
Example 2
Source File: FormDataParserTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@Test public void blockingParser() throws Exception { final BlockingHandler blocking = new BlockingHandler(); blocking.setRootHandler(new HttpHandler() { @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final FormParserFactory parserFactory = FormParserFactory.builder().build(); final FormDataParser parser = parserFactory.createParser(exchange); try { FormData data = parser.parseBlocking(); Iterator<String> it = data.iterator(); while (it.hasNext()) { String fd = it.next(); for (FormData.FormValue val : data.get(fd)) { exchange.addResponseHeader("res", fd + ":" + val.getValue()); } } } catch (IOException e) { exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR); } } }); DefaultServer.setRootHandler(blocking); testCase(); }