Search in sources :

Example 1 with RequestNotExecutedException

use of org.apache.hc.core5.http.RequestNotExecutedException in project httpcomponents-core by apache.

the class CommandSupport method cancelCommands.

/**
 * Cancels all pending session {@link Command}s.
 */
public static void cancelCommands(final IOSession ioSession) {
    Args.notNull(ioSession, "I/O session");
    Command command;
    while ((command = ioSession.poll()) != null) {
        if (command instanceof ExecutableCommand) {
            if (!ioSession.isOpen()) {
                ((ExecutableCommand) command).failed(new RequestNotExecutedException());
            } else {
                command.cancel();
            }
        } else {
            command.cancel();
        }
    }
}
Also used : Command(org.apache.hc.core5.reactor.Command) RequestNotExecutedException(org.apache.hc.core5.http.RequestNotExecutedException)

Aggregations

RequestNotExecutedException (org.apache.hc.core5.http.RequestNotExecutedException)1 Command (org.apache.hc.core5.reactor.Command)1