List of usage examples for org.apache.http.nio.protocol HttpAsyncExchange submitResponse
void submitResponse(HttpAsyncResponseProducer responseProducer);
From source file:com.mycompany.allasync.NHttpRequestHandler.java
public void handle(final HttpRequest request, final HttpAsyncExchange httpexchange, final HttpContext context) throws HttpException, IOException { HttpResponse response = httpexchange.getResponse(); handleInternal(request, response, context); httpexchange.submitResponse(new BasicAsyncResponseProducer(response)); }
From source file:org.callimachusproject.server.helpers.Exchange.java
public synchronized void setHttpAsyncExchange(HttpAsyncExchange exchange) { assert exchange != null; this.exchange = exchange; exchange.setCallback(this); if (timeout != -1) { exchange.setTimeout(timeout);//ww w . j a va 2s.c om } if (response != null) { exchange.submitResponse(producer = new LoggingResponseProducer(response)); } else if (submitContinue != null) { exchange.submitResponse(submitContinue); } }
From source file:talkeeg.server.BarcodeProvider.java
@Override public void handle(HttpRequest data, HttpAsyncExchange httpExchange, HttpContext context) throws HttpException, IOException { final BinaryData barcodeData = this.helloProvider.get().helloAsBinaryData(); final BitMatrix matrix = this.barcodeServiceProvider.get().encode(barcodeData); final BufferedImage image = BarcodeUtilsSE.toBufferedImage(matrix); ByteArrayOutputStream tmp = new ByteArrayOutputStream(); ImageIO.write(image, "png", tmp); final HttpResponse response = httpExchange.getResponse(); response.setHeader("Content-Type", "image/png"); response.setEntity(new ByteArrayEntity(tmp.toByteArray())); response.setStatusCode(HttpStatus.SC_OK); httpExchange.submitResponse(new BasicAsyncResponseProducer(response)); }