Search in sources :

Example 6 with BlockingHandler

use of io.undertow.server.handlers.BlockingHandler in project undertow by undertow-io.

the class ContentOverrunTestCase method setup.

@BeforeClass
public static void setup() {
    HttpHandler overlyLong = new HttpHandler() {

        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.setResponseContentLength(10);
            exchange.getOutputStream().write("Overly long content".getBytes(StandardCharsets.UTF_8));
        }
    };
    HttpHandler responseNotAllowed = new HttpHandler() {

        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            exchange.setStatusCode(204);
            exchange.getOutputStream().write("Overly long content".getBytes(StandardCharsets.UTF_8));
        }
    };
    DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/204", new BlockingHandler(responseNotAllowed)).addPrefixPath("/long", new BlockingHandler(overlyLong)));
}
Also used : HttpServerExchange(io.undertow.server.HttpServerExchange) HttpHandler(io.undertow.server.HttpHandler) BlockingHandler(io.undertow.server.handlers.BlockingHandler) BeforeClass(org.junit.BeforeClass)

Aggregations

BlockingHandler (io.undertow.server.handlers.BlockingHandler)6 HttpHandler (io.undertow.server.HttpHandler)3 HttpServerExchange (io.undertow.server.HttpServerExchange)3 IOException (java.io.IOException)3 BeforeClass (org.junit.BeforeClass)3 TestHttpClient (io.undertow.testutils.TestHttpClient)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 HttpResponse (org.apache.http.HttpResponse)2 HttpPost (org.apache.http.client.methods.HttpPost)2 Test (org.junit.Test)2 IoCallback (io.undertow.io.IoCallback)1 Sender (io.undertow.io.Sender)1 HttpString (io.undertow.util.HttpString)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 StringEntity (org.apache.http.entity.StringEntity)1 MultipartEntity (org.apache.http.entity.mime.MultipartEntity)1