@Override public void onComplete(final HttpServerExchange exchange, final Sender sender) { if (exchange.isInIoThread()) { exchange.dispatch(this); } else { run(); } }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.startBlocking(); if (exchange.isInIoThread()) { exchange.dispatch(handler); } else { handler.handleRequest(exchange); } }
if (exchange.isInIoThread()) { exchange.dispatch(serveTask); } else {
if (exchange.isInIoThread()) { exchange.dispatch(task); } else {
return; if (exchange.isInIoThread()) { throw UndertowMessages.MESSAGES.blockingIoFromIOThread();
throw new RuntimeException(e); if (exchange.isInIoThread()) { exchange.dispatch(task); } else {
if(exchange.isInIoThread()) {
/** * Try to open a socket connection to given address. * * @param address the socket address * @param exchange the http servers exchange * @param callback the ping callback * @param options the options */ static void pingHost(InetSocketAddress address, HttpServerExchange exchange, PingCallback callback, OptionMap options) { final XnioIoThread thread = exchange.getIoThread(); final XnioWorker worker = thread.getWorker(); final HostPingTask r = new HostPingTask(address, worker, callback, options); // Schedule timeout task scheduleCancelTask(exchange.getIoThread(), r, 5, TimeUnit.SECONDS); exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r); }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { exchange.endExchange(); } }
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : exchange.getIoThread(), new Runnable() { @Override public void run() {
@Override public void transferFrom(FileChannel source, IoCallback callback) { if (callback == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("callback"); } if(!exchange.getConnection().isOpen()) { invokeOnException(callback, new ClosedChannelException()); return; } if(exchange.isResponseComplete()) { invokeOnException(callback, new IOException(UndertowMessages.MESSAGES.responseComplete())); } if (this.fileChannel != null || this.buffer != null) { throw UndertowMessages.MESSAGES.dataAlreadyQueued(); } this.callback = callback; this.fileChannel = source; if (inCallback) { return; } if(transferTask == null) { transferTask = new TransferTask(); } if (exchange.isInIoThread()) { exchange.dispatch(transferTask); return; } transferTask.run(); }
if (exchange.isInIoThread()) { exchange.dispatch(this); return; if (exchange.isInIoThread()) { exchange.dispatch(this); return;
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if (exchange.isInIoThread()) { HeaderValues upgrade = exchange.getRequestHeaders().get(Headers.UPGRADE); if (upgrade != null && upgrade.contains("h2c")) { // reset protocol exchange.setProtocol(Protocols.HTTP_1_1); } exchange.dispatch(this); return; } handler.handle(new UndertowRequest(exchange, config), new UndertowResponse(exchange)); }
/** * Try to ping a server using the undertow client. * * @param connection the connection URI * @param callback the ping callback * @param exchange the http servers exchange * @param client the undertow client * @param xnioSsl the ssl setup * @param options the options */ static void pingHttpClient(URI connection, PingCallback callback, HttpServerExchange exchange, UndertowClient client, XnioSsl xnioSsl, OptionMap options) { final XnioIoThread thread = exchange.getIoThread(); final RequestExchangeListener exchangeListener = new RequestExchangeListener(callback, NodeHealthChecker.NO_CHECK, true); final Runnable r = new HttpClientPingTask(connection, exchangeListener, thread, client, xnioSsl, exchange.getConnection().getByteBufferPool(), options); exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : thread, r); // Schedule timeout task scheduleCancelTask(exchange.getIoThread(), exchangeListener, 5, TimeUnit.SECONDS); }
@Override public final void handleRequest(HttpServerExchange exchange) throws Exception { if (exchange.isInIoThread()) { if (executorService == null) { exchange.dispatch(this); } else { exchange.putAttachment(EXECUTOR, executorService); exchange.dispatch(executorService, this); } return; } else if (executorService != null && exchange.getAttachment(EXECUTOR) == null) { exchange.putAttachment(EXECUTOR, executorService); exchange.dispatch(executorService, this); return; } exchange.startBlocking(); handleInternal(exchange); }
exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : exchange.getIoThread(), clientHandler);
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if (exchange.isInIoThread()) { exchange.dispatch(this); return; } if(isEnabled()) { Map<String, Object> result = new LinkedHashMap<>(); //create rootDumper which will do dumping. RootDumper rootDumper = new RootDumper(config, exchange); //dump request info into result right away rootDumper.dumpRequest(result); //only add response wrapper when response config is not set to "false" if(config.isResponseEnabled()) { //set Conduit to the conduit chain to store response body exchange.addResponseWrapper((factory, exchange12) -> new StoreResponseStreamSinkConduit(factory.create(), exchange12)); } //when complete exchange, dump response info to result, and log the result. exchange.addExchangeCompleteListener((exchange1, nextListener) ->{ rootDumper.dumpResponse(result); //log the result DumpHelper.logResult(result, config); nextListener.proceed(); }); } Handler.next(exchange, next); } }
if(exchange.isInIoThread()) { exchange.dispatch(dispatchTask); } else {
if (exchange.isInIoThread()) { exchange.dispatch(this); return;
if (exchange.isInIoThread()) { if (exchange.isInIoThread()) { requestStateUpdater.set(this, 0); //no need to CAS, as we don't actually resume newRequest();