Search in sources :

Example 1 with ClientResponseFilter

use of jakarta.ws.rs.client.ClientResponseFilter in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method setCorruptedStream.

protected AtomicInteger setCorruptedStream() {
    final AtomicInteger ai = new AtomicInteger(0);
    ClientResponseFilter filter = new ClientResponseFilter() {

        @Override
        public void filter(ClientRequestContext arg0, ClientResponseContext response) throws IOException {
            CorruptedInputStream cis = new CorruptedInputStream(ResponseTest.ENTITY.getBytes(), ai);
            cis.setCorrupted(true);
            response.setEntityStream(cis);
        }
    };
    addProvider(filter);
    // do not use new entity stream in logging filter for the case of priority
    // disfunction, the CorruptedInputStream would be then replaced, wrongly
    // informing about not closing the stream
    super.setPrintEntity(false);
    return ai;
}
Also used : ClientRequestContext(jakarta.ws.rs.client.ClientRequestContext) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ClientResponseFilter(jakarta.ws.rs.client.ClientResponseFilter) ClientResponseContext(jakarta.ws.rs.client.ClientResponseContext)

Aggregations

ClientRequestContext (jakarta.ws.rs.client.ClientRequestContext)1 ClientResponseContext (jakarta.ws.rs.client.ClientResponseContext)1 ClientResponseFilter (jakarta.ws.rs.client.ClientResponseFilter)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1