diff --git a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java index cd104d41cb..bc3ee2c800 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java @@ -81,19 +81,19 @@ public class DecoderHttpMessageReader implements ServerHttpMessageReader { } @Override - public Flux read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, + public Flux read(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { - MediaType contentType = getContentType(inputMessage); - return this.decoder.decode(inputMessage.getBody(), elementType, contentType, hints); + MediaType contentType = getContentType(message); + return this.decoder.decode(message.getBody(), elementType, contentType, hints); } @Override - public Mono readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, + public Mono readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { - MediaType contentType = getContentType(inputMessage); - return this.decoder.decodeToMono(inputMessage.getBody(), elementType, contentType, hints); + MediaType contentType = getContentType(message); + return this.decoder.decodeToMono(message.getBody(), elementType, contentType, hints); } private MediaType getContentType(HttpMessage inputMessage) { @@ -105,22 +105,22 @@ public class DecoderHttpMessageReader implements ServerHttpMessageReader { // ServerHttpMessageReader... @Override - public Flux read(ResolvableType streamType, ResolvableType elementType, + public Flux read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map hints) { Map allHints = new HashMap<>(4); - allHints.putAll(getReadHints(streamType, elementType, request, response)); + allHints.putAll(getReadHints(actualType, elementType, request, response)); allHints.putAll(hints); return read(elementType, request, allHints); } @Override - public Mono readMono(ResolvableType streamType, ResolvableType elementType, + public Mono readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map hints) { Map allHints = new HashMap<>(4); - allHints.putAll(getReadHints(streamType, elementType, request, response)); + allHints.putAll(getReadHints(actualType, elementType, request, response)); allHints.putAll(hints); return readMono(elementType, request, allHints); diff --git a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java index 0a9dfa6166..c16d534699 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java @@ -120,10 +120,10 @@ public class EncoderHttpMessageWriter implements ServerHttpMessageWriter { @Override public Mono write(Publisher inputStream, ResolvableType elementType, - MediaType mediaType, ReactiveHttpOutputMessage outputMessage, + MediaType mediaType, ReactiveHttpOutputMessage message, Map hints) { - HttpHeaders headers = outputMessage.getHeaders(); + HttpHeaders headers = message.getHeaders(); if (headers.getContentType() == null) { MediaType fallback = this.defaultMediaType; @@ -135,11 +135,11 @@ public class EncoderHttpMessageWriter implements ServerHttpMessageWriter { } Flux body = this.encoder.encode(inputStream, - outputMessage.bufferFactory(), elementType, headers.getContentType(), hints); + message.bufferFactory(), elementType, headers.getContentType(), hints); return isStreamingMediaType(headers.getContentType()) ? - outputMessage.writeAndFlushWith(body.map(Flux::just)) : - outputMessage.writeWith(body); + message.writeAndFlushWith(body.map(Flux::just)) : + message.writeWith(body); } private static boolean useFallback(MediaType main, MediaType fallback) { @@ -162,12 +162,12 @@ public class EncoderHttpMessageWriter implements ServerHttpMessageWriter { // ServerHttpMessageWriter... @Override - public Mono write(Publisher inputStream, ResolvableType streamType, + public Mono write(Publisher inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map hints) { Map allHints = new HashMap<>(); - allHints.putAll(getWriteHints(streamType, elementType, mediaType, request, response)); + allHints.putAll(getWriteHints(actualType, elementType, mediaType, request, response)); allHints.putAll(hints); return write(inputStream, elementType, mediaType, response, allHints); diff --git a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java index edafcd0650..c66690b446 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageReader.java @@ -83,19 +83,19 @@ public class FormHttpMessageReader implements HttpMessageReader> read(ResolvableType elementType, - ReactiveHttpInputMessage inputMessage, Map hints) { + ReactiveHttpInputMessage message, Map hints) { - return Flux.from(readMono(elementType, inputMessage, hints)); + return Flux.from(readMono(elementType, message, hints)); } @Override public Mono> readMono(ResolvableType elementType, - ReactiveHttpInputMessage inputMessage, Map hints) { + ReactiveHttpInputMessage message, Map hints) { - MediaType contentType = inputMessage.getHeaders().getContentType(); + MediaType contentType = message.getHeaders().getContentType(); Charset charset = getMediaTypeCharset(contentType); - return inputMessage.getBody() + return message.getBody() .reduce(DataBuffer::write) .map(buffer -> { CharBuffer charBuffer = charset.decode(buffer.asByteBuffer()); diff --git a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java index 0e04e85f94..a5070a9517 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/FormHttpMessageWriter.java @@ -82,13 +82,13 @@ public class FormHttpMessageWriter implements HttpMessageWriter write(Publisher> inputStream, - ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, + ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map hints) { - MediaType contentType = outputMessage.getHeaders().getContentType(); + MediaType contentType = message.getHeaders().getContentType(); if (contentType == null) { contentType = MediaType.APPLICATION_FORM_URLENCODED; - outputMessage.getHeaders().setContentType(contentType); + message.getHeaders().setContentType(contentType); } Charset charset = getMediaTypeCharset(contentType); @@ -99,9 +99,9 @@ public class FormHttpMessageWriter implements HttpMessageWriter generateForm(form, charset)) .then(value -> { ByteBuffer byteBuffer = charset.encode(value); - DataBuffer buffer = outputMessage.bufferFactory().wrap(byteBuffer); - outputMessage.getHeaders().setContentLength(byteBuffer.remaining()); - return outputMessage.writeWith(Mono.just(buffer)); + DataBuffer buffer = message.bufferFactory().wrap(byteBuffer); + message.getHeaders().setContentLength(byteBuffer.remaining()); + return message.writeWith(Mono.just(buffer)); }); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/HttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/HttpMessageReader.java index a72d7ff03e..009de9b0d8 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/HttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/HttpMessageReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,10 @@ import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpInputMessage; /** - * Strategy interface that specifies a reader that can convert from the HTTP - * request body from a stream of bytes to Objects. + * Strategy for reading from a {@link ReactiveHttpInputMessage} and decoding + * the stream of bytes to Objects of type {@code }. + * + * @param the type of objects in the decoded output stream * * @author Rossen Stoyanchev * @author Arjen Poutsma @@ -38,40 +40,39 @@ import org.springframework.http.ReactiveHttpInputMessage; public interface HttpMessageReader { /** - * Indicates whether the given class can be read by this converter. - * @param elementType the stream element type to test for readability - * @param mediaType the media type to read, can be {@code null} if not specified. - * Typically the value of a {@code Content-Type} header. - * @return {@code true} if readable; {@code false} otherwise + * Return the {@link MediaType}'s that this reader supports. + */ + List getReadableMediaTypes(); + + /** + * Whether the given object type is supported by this reader. + * @param elementType the type of object to check + * @param mediaType the media type for the read, possibly {@code null} + * @return {@code true} if readable, {@code false} otherwise */ boolean canRead(ResolvableType elementType, MediaType mediaType); /** - * Read a {@link Flux} of the given type form the given input message, and returns it. - * @param elementType the stream element type to return. This type must have previously been - * passed to the {@link #canRead canRead} method of this interface, which must have - * returned {@code true}. - * @param inputMessage the HTTP input message to read from - * @param hints additional information about how to read the body - * @return the converted {@link Flux} of elements + * Read from the input message and encode to a stream of objects. + * + * @param elementType the type of objects in the stream which must have been + * previously checked via {@link #canRead(ResolvableType, MediaType)} + * @param message the message to read from + * @param hints additional information about how to read and decode the input + * @return the decoded stream of elements */ - Flux read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map hints); + Flux read(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints); /** - * Read a {@link Mono} of the given type form the given input message, and returns it. - * @param elementType the stream element type to return. This type must have previously been - * passed to the {@link #canRead canRead} method of this interface, which must have - * returned {@code true}. - * @param inputMessage the HTTP input message to read from - * @param hints additional information about how to read the body - * @return the converted {@link Mono} of object + * Read from the input message and encode to a single object. + * + * @param elementType the type of objects in the stream which must have been + * previously checked via {@link #canRead(ResolvableType, MediaType)} + * @param message the message to read from + * @param hints additional information about how to read and decode the input + * @return the decoded object */ - Mono readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map hints); + Mono readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints); - /** - * Return the list of {@link MediaType} objects that can be read by this converter. - * @return the list of supported readable media types - */ - List getReadableMediaTypes(); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/HttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/HttpMessageWriter.java index 8a2f769aff..6083f905fa 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/HttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/HttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,10 @@ import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; /** - * Strategy interface that specifies a converter that can convert a stream of - * Objects to a stream of bytes to be written to the HTTP response body. + * Strategy for encoding a stream of objects of type {@code } and writing + * the encoded stream of bytes to an {@link ReactiveHttpOutputMessage}. + * + * @param the type of objects in the input stream * * @author Rossen Stoyanchev * @author Arjen Poutsma @@ -38,34 +40,31 @@ import org.springframework.http.ReactiveHttpOutputMessage; public interface HttpMessageWriter { /** - * Indicates whether the given class can be written by this converter. - * @param elementType the stream element type to test for writability - * @param mediaType the media type to write, can be {@code null} if not specified. - * Typically the value of an {@code Accept} header. - * @return {@code true} if writable; {@code false} otherwise + * Return the {@link MediaType}'s that this writer supports. + */ + List getWritableMediaTypes(); + + /** + * Whether the given object type is supported by this writer. + * @param elementType the type of object to check + * @param mediaType the media type for the write, possibly {@code null} + * @return {@code true} if writable, {@code false} otherwise */ boolean canWrite(ResolvableType elementType, MediaType mediaType); /** - * Write an given object to the given output message. - * @param inputStream the input stream to write - * @param elementType the stream element type to process. This type must have previously - * been passed to the {@link #canWrite} canWrite} method of this interface, which must - * have returned {@code true}. - * @param mediaType the content type to use when writing, typically the value of an - * {@code Accept} header. May be {@code null} to indicate that the default content - * type of the converter must be used. - * @param outputMessage the message to write to - * @param hints additional information about how to write - * @return a {@link Mono} that indicates completion or error + * Write an given stream of object to the output message. + * @param inputStream the objects to write + * @param elementType the type of objects in the stream which must have been + * previously checked via {@link #canWrite(ResolvableType, MediaType)} + * @param mediaType the content type for the write, possibly {@code null} to + * indicate that the default content type of the writer must be used. + * @param message the message to write to + * @param hints additional information about how to encode and write + * @return indicates completion or error */ Mono write(Publisher inputStream, ResolvableType elementType, - MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map hints); + MediaType mediaType, ReactiveHttpOutputMessage message, Map hints); - /** - * Return the list of {@link MediaType} objects that can be written by this converter. - * @return the list of supported readable media types - */ - List getWritableMediaTypes(); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java index 2f72b7210d..3765d7ecc4 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java @@ -176,7 +176,7 @@ public class ResourceHttpMessageWriter implements ServerHttpMessageWriter write(Publisher inputStream, ResolvableType streamType, + public Mono write(Publisher inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map hints) { diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpDecoder.java b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpDecoder.java index fc256c9bd9..f5b5dddf1f 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpDecoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpDecoder.java @@ -31,7 +31,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse; */ public interface ServerHttpDecoder extends Decoder { - /** * Get decoding hints based on the server request or annotations on the * target controller method parameter. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpEncoder.java b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpEncoder.java index 20bc06583f..7b5fa512b6 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpEncoder.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpEncoder.java @@ -33,7 +33,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse; */ public interface ServerHttpEncoder extends Encoder { - /** * Get decoding hints based on the server request or annotations on the * target controller method parameter. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageReader.java index 5574f79f2d..1509b42ddd 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,46 +27,43 @@ import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; /** - * Server oriented {@link HttpMessageReader} that allows to resolve hints using annotations or - * perform additional operation using {@link ServerHttpRequest} or {@link ServerHttpResponse}. + * An extension of {@code HttpMessageReader} for decoding and reading the + * request body with extra information available on the server side. * * @author Sebastien Deleuze + * @author Rossen Stoyanchev * @since 5.0 */ public interface ServerHttpMessageReader extends HttpMessageReader { /** - * Read a {@link Flux} of the given type form the given input message with additional server related - * parameters which could be used to create some hints or set the response status for example. + * Decode and read the request body to an object stream. * - * Return hints that can be used to customize how the body should be read - * @param streamType the original type used in the method parameter. For annotation - * based controllers, the {@link MethodParameter} is available via {@link ResolvableType#getSource()}. - * @param elementType the stream element type to return - * Typically the value of a {@code Content-Type} header. - * @param request the current HTTP request - * @param response the current HTTP response + * @param actualType the actual type of the target method parameter; for + * annotated controllers, the {@link MethodParameter} can be accessed via + * {@link ResolvableType#getSource()}. + * @param elementType the type of Objects in the output stream + * @param request the current request + * @param response the current response * @param hints additional information about how to read the body - * @return the converted {@link Flux} of elements + * @return the decoded stream of elements */ - Flux read(ResolvableType streamType, ResolvableType elementType, ServerHttpRequest request, + Flux read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map hints); /** - * Read a {@link Mono} of the given type form the given input message with additional server related - * parameters which could be used to create some hints or set the response status for example. + * Decode and read the request body to a single object. * - * Return hints that can be used to customize how the body should be read - * @param streamType the original type used in the method parameter. For annotation - * based controllers, the {@link MethodParameter} is available via {@link ResolvableType#getSource()}. - * @param elementType the stream element type to return - * Typically the value of a {@code Content-Type} header. - * @param request the current HTTP request - * @param response the current HTTP response + * @param actualType the actual type of the target method parameter; for + * annotated controllers, the {@link MethodParameter} can be accessed via + * {@link ResolvableType#getSource()}. + * @param elementType the type of Objects in the output stream + * @param request the current request + * @param response the current response * @param hints additional information about how to read the body - * @return the converted {@link Mono} of object + * @return the decoded stream of elements */ - Mono readMono(ResolvableType streamType, ResolvableType elementType, ServerHttpRequest request, + Mono readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map hints); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageWriter.java index 518e63b58f..5758d728c5 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,29 +28,29 @@ import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; /** - * Server oriented {@link HttpMessageWriter} that allows to resolve hints using annotations or - * perform additional operation using {@link ServerHttpRequest} or {@link ServerHttpResponse}. + * An extension of {@code HttpMessageWriter} for encoding and writing the + * response body with extra information available on the server side. * * @author Sebastien Deleuze + * @author Rossen Stoyanchev * @since 5.0 */ public interface ServerHttpMessageWriter extends HttpMessageWriter { /** - * Write a given object to the given output message with additional server related - * parameters which could be used to create some hints or set the response status for example. + * Encode and write the given object stream to the response. * - * @param streamType the original type used for the method return value. For annotation - * based controllers, the {@link MethodParameter} is available via {@link ResolvableType#getSource()}. - * Can be {@code null}. - * @param elementType the stream element type to process - * @param mediaType the content type to use when writing. May be {@code null} to - * indicate that the default content type of the converter must be used. - * @param request the current HTTP request - * @param response the current HTTP response - * @return a {@link Mono} that indicates completion or error + * @param actualType the actual return type of the method that returned the + * value; for annotated controllers, the {@link MethodParameter} can be + * accessed via {@link ResolvableType#getSource()}. + * @param elementType the type of Objects in the input stream + * @param mediaType the content type to use, possibly {@code null} indicating + * the default content type of the writer should be used. + * @param request the current request + * @param response the current response + * @return a {@link Mono} that indicates completion of writing or error */ - Mono write(Publisher inputStream, ResolvableType streamType, + Mono write(Publisher inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map hints); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index ee9f4ffc9a..bf2e182107 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -87,13 +87,13 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader read(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, + public Flux read(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { boolean hasSseWrapper = ServerSentEvent.class.isAssignableFrom(elementType.getRawClass()); ResolvableType dataType = (hasSseWrapper ? elementType.getGeneric(0) : elementType); - return Flux.from(inputMessage.getBody()) + return Flux.from(message.getBody()) .concatMap(ServerSentEventHttpMessageReader::splitOnNewline) .map(buffer -> { CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer()); @@ -178,13 +178,13 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, + public Mono readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map hints) { // Let's give StringDecoder a chance since SSE is ordered ahead of it if (String.class.equals(elementType.getRawClass())) { - Flux body = inputMessage.getBody(); + Flux body = message.getBody(); return stringDecoder.decodeToMono(body, elementType, null, null).cast(Object.class); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java index 7f2032b137..b25daae2f1 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java @@ -87,14 +87,14 @@ public class ServerSentEventHttpMessageWriter implements ServerHttpMessageWriter @Override public Mono write(Publisher inputStream, ResolvableType elementType, MediaType mediaType, - ReactiveHttpOutputMessage outputMessage, Map hints) { + ReactiveHttpOutputMessage message, Map hints) { - outputMessage.getHeaders().setContentType(MediaType.TEXT_EVENT_STREAM); + message.getHeaders().setContentType(MediaType.TEXT_EVENT_STREAM); - DataBufferFactory bufferFactory = outputMessage.bufferFactory(); + DataBufferFactory bufferFactory = message.bufferFactory(); Flux> body = encode(inputStream, bufferFactory, elementType, hints); - return outputMessage.writeAndFlushWith(body); + return message.writeAndFlushWith(body); } private Flux> encode(Publisher inputStream, DataBufferFactory bufferFactory, @@ -164,14 +164,14 @@ public class ServerSentEventHttpMessageWriter implements ServerHttpMessageWriter } @Override - public Mono write(Publisher inputStream, ResolvableType streamType, ResolvableType elementType, + public Mono write(Publisher inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map hints) { Map allHints = this.dataEncoders.stream() .filter(encoder -> encoder instanceof ServerHttpEncoder) .map(encoder -> (ServerHttpEncoder) encoder) - .map(encoder -> encoder.getEncodeHints(streamType, elementType, mediaType, request, response)) + .map(encoder -> encoder.getEncodeHints(actualType, elementType, mediaType, request, response)) .reduce(new HashMap<>(), (t, u) -> { t.putAll(u); return t; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index 314759c3f3..c54387fe82 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -97,7 +97,7 @@ public class ExchangeStrategiesTests { @Override public Mono write(Publisher inputStream, ResolvableType type, MediaType contentType, - ReactiveHttpOutputMessage outputMessage, + ReactiveHttpOutputMessage message, Map hints) { return Mono.empty(); } @@ -117,13 +117,13 @@ public class ExchangeStrategiesTests { } @Override - public Flux read(ResolvableType type, ReactiveHttpInputMessage inputMessage, + public Flux read(ResolvableType type, ReactiveHttpInputMessage message, Map hints) { return Flux.empty(); } @Override - public Mono readMono(ResolvableType type, ReactiveHttpInputMessage inputMessage, + public Mono readMono(ResolvableType type, ReactiveHttpInputMessage message, Map hints) { return Mono.empty(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java index 0c94874eeb..8a32fc2911 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java @@ -99,7 +99,7 @@ public class HandlerStrategiesTests { @Override public Mono write(Publisher inputStream, ResolvableType type, MediaType contentType, - ReactiveHttpOutputMessage outputMessage, + ReactiveHttpOutputMessage message, Map hints) { return Mono.empty(); } @@ -119,13 +119,13 @@ public class HandlerStrategiesTests { } @Override - public Flux read(ResolvableType type, ReactiveHttpInputMessage inputMessage, + public Flux read(ResolvableType type, ReactiveHttpInputMessage message, Map hints) { return Flux.empty(); } @Override - public Mono readMono(ResolvableType type, ReactiveHttpInputMessage inputMessage, + public Mono readMono(ResolvableType type, ReactiveHttpInputMessage message, Map hints) { return Mono.empty(); }