Example usage for org.springframework.http ReactiveHttpInputMessage getBody

List of usage examples for org.springframework.http ReactiveHttpInputMessage getBody

Introduction

In this page you can find the example usage for org.springframework.http ReactiveHttpInputMessage getBody.

Prototype

Flux<DataBuffer> getBody();

Source Link

Document

Return the body of the message as a Publisher .

Usage

From source file:org.springframework.http.codec.DecoderHttpMessageReader.java

@Override
public Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) {
    MediaType contentType = getContentType(message);
    return this.decoder.decode(message.getBody(), elementType, contentType, hints);
}

From source file:org.springframework.http.codec.DecoderHttpMessageReader.java

@Override
public Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message,
        Map<String, Object> hints) {
    MediaType contentType = getContentType(message);
    return this.decoder.decodeToMono(message.getBody(), elementType, contentType, hints);
}

From source file:org.springframework.http.codec.multipart.DefaultMultipartMessageReader.java

@Override
public Flux<Part> read(ResolvableType elementType, ReactiveHttpInputMessage message,
        Map<String, Object> hints) {
    byte[] boundary = boundary(message);
    if (boundary == null) {
        return Flux.error(new CodecException("No multipart boundary found in Content-Type: \""
                + message.getHeaders().getContentType() + "\""));
    }//from w  w w .j  a va2 s.  c  om
    if (logger.isTraceEnabled()) {
        logger.trace("Boundary: " + toString(boundary));
    }

    byte[] boundaryNeedle = concat(BOUNDARY_PREFIX, boundary);
    Flux<DataBuffer> body = skipUntilFirstBoundary(message.getBody(), boundary);

    return DataBufferUtils.split(body, boundaryNeedle).takeWhile(DefaultMultipartMessageReader::notLastBoundary)
            .map(DefaultMultipartMessageReader::toPart)
            .doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)
            .doOnDiscard(DefaultPart.class, part -> DataBufferUtils.release(part.body));
}