restjax-rsquarkus

Access HTTP Trailer in Quarkus


I'm implementing a REST-API in Quarkus and want to stream the content.

I want the know when the tranpsort of the stream is finished. As the http-standard describes, http-trailer fields will be sent, when the transport of the message-body is finished. Therefore I want to access the http-trailer in quarkus (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer).

How do I access the http trailer information in quarkus?

Thanks for your support.

I've read the documentation - there is only some documentation about grpc, where you can use the http-trailers:

https://quarkus.io/guides/grpc-service-consumption

But I need the information in Quarkus REST.


Solution

  • The Vert.x HTTP Client gives you access to HTTP trailers via io.vertx.core.http.HttpClientResponse#trailers.

    You can manually create a Vert.x HTTP client in Quarkus doing something like:

    @Singleton
    public MyClass {
    
        private final Vertx vertx;
        private final WebClient client;            
        
        public MyClass(Vertx vertx) {
            this.vertx = vertx;
            this.client = WebClient.create(vertx); 
        }
    
    }
    

    See this for more information.