private void write(HttpObject o, boolean endOfStream) {
        if (!ch.isActive()) {
            PooledObjects.close(o);
            fail(newClosedSessionException(ch));
            return;
        }

        if (endOfStream) {
            state = State.DONE;
        }

        if (isStreamOrSessionClosed()) {
            PooledObjects.close(o);
            return;
        }

        final ChannelFuture future;
        if (o instanceof HttpHeaders) {
            future = encoder.writeTrailers(id, streamId(), (HttpHeaders) o);
        } else {
            future = encoder.writeData(id, streamId(), (HttpData) o, endOfStream);
        }

        future.addListener(this);
    }
Writes the {@link HttpHeaders trailers} to the {@link Channel}.
Note that the written data is not flushed by this method. The caller should explicitly call
{@link Channel#flush()} when each write unit is done.
core/src/main/java/com/linecorp/armeria/client/AbstractHttpRequestHandler.java