use of org.springframework.core.io.buffer.DataBufferFactory in project spring-framework by spring-projects.
the class AbstractEncoderMethodReturnValueHandler method handleReturnValue.
@Override
public Mono<Void> handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message) {
if (returnValue == null) {
return handleNoContent(returnType, message);
}
DataBufferFactory bufferFactory = (DataBufferFactory) message.getHeaders().getOrDefault(HandlerMethodReturnValueHandler.DATA_BUFFER_FACTORY_HEADER, DefaultDataBufferFactory.sharedInstance);
MimeType mimeType = (MimeType) message.getHeaders().get(MessageHeaders.CONTENT_TYPE);
Flux<DataBuffer> encodedContent = encodeContent(returnValue, returnType, bufferFactory, mimeType, Collections.emptyMap());
return new ChannelSendOperator<>(encodedContent, publisher -> handleEncodedContent(Flux.from(publisher), returnType, message));
}
use of org.springframework.core.io.buffer.DataBufferFactory in project spring-security by spring-projects.
the class LoginPageGeneratingWebFilter method createBuffer.
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
return token.map(LoginPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
byte[] bytes = createPage(exchange, csrfTokenHtmlInput);
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
return bufferFactory.wrap(bytes);
});
}
use of org.springframework.core.io.buffer.DataBufferFactory in project spring-security by spring-projects.
the class LogoutPageGeneratingWebFilter method createBuffer.
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
return token.map(LogoutPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
byte[] bytes = createPage(csrfTokenHtmlInput);
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
return bufferFactory.wrap(bytes);
});
}
Aggregations