Example usage for org.springframework.web.reactive.function BodyExtractors toDataBuffers

List of usage examples for org.springframework.web.reactive.function BodyExtractors toDataBuffers

Introduction

In this page you can find the example usage for org.springframework.web.reactive.function BodyExtractors toDataBuffers.

Prototype

public static BodyExtractor<Flux<DataBuffer>, ReactiveHttpInputMessage> toDataBuffers() 

Source Link

Document

Extractor that returns the raw DataBuffer DataBuffers .

Usage

From source file:org.springframework.cloud.gateway.filter.WebClientWriteResponseFilter.java

@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
    // NOTICE: nothing in "pre" filter stage as CLIENT_RESPONSE_ATTR is not added
    // until the WebHandler is run
    return chain.filter(exchange).then(Mono.defer(() -> {
        ClientResponse clientResponse = exchange.getAttribute(CLIENT_RESPONSE_ATTR);
        if (clientResponse == null) {
            return Mono.empty();
        }//from w ww  . j  ava 2s  .  co  m
        log.trace("WebClientWriteResponseFilter start");
        ServerHttpResponse response = exchange.getResponse();

        return response.writeWith(clientResponse.body(BodyExtractors.toDataBuffers()))
                .log("webClient response");
    }));
}