private void deliver(@Nonnull final HttpConnection connection, @Nonnull final List<Deliverable> deliverables, final boolean async)
        throws HttpConnectionClosedException, IOException
    {
        Log.trace("Delivering {} deliverables to the client on session {}, using connection with RID {}", deliverables.size(), getStreamID(), connection.getRequestId());
        connection.deliverBody(asBodyText(deliverables), async);
        lastAnsweredRequestID = connection.getRequestId();

        lastActivity = Instant.now();

        for (final Deliverable deliverable : deliverables) {
            for (int i=0; i<deliverable.stanzaCount(); i++) {
                incrementServerPacketCount();
            }
        }

        // Keep track of data that has been delivered, for potential future retransmission.
        final Delivered delivered = new Delivered(deliverables, connection.getRequestId());
        synchronized (sentElements) {
            while (sentElements.size() > maxRequests) {
                sentElements.poll();
            }

            sentElements.add(delivered);
        }
    }
Uses a connection to return data to the client.

@param connection The connection to use return data.
@param deliverables The data to be delivered.
@param async should the invocation block until the data has been delivered?
xmppserver/src/main/java/org/jivesoftware/openfire/http/HttpSession.java