private HttpMessageSubscriber asSubscriber() {
        return new HttpMessageSubscriber() {
            @Override
            public void onData(HttpData data) {
                content.add(data.byteBuf());
            }

            @Override
            public void onHeaders(HttpHeaders headers) {
                headersBuilder.add(headers);
                if (!headersFuture.isDone()) {
                    headersFuture.complete(headers());
                }
            }

            @Override
            public void onError(Throwable cause) {
                content.interrupt(cause);
                if (!headersFuture.isDone()) {
                    headersFuture.complete(headers());
                }
            }

            @Override
            public void onComplete() {
                content.setEos(); // signal the end of stream
                if (!headersFuture.isDone()) {
                    headersFuture.complete(headers());
                }
            }
        };
    }
Returns a snapshot of the available headers.
resteasy/src/main/java/com/linecorp/armeria/internal/common/resteasy/HttpMessageStream.java