Fix regression in client codecs

Restore the correct client-side default for whether StringDecoder
should split on new lines. It is true forthe server and false for the
client by default.

The regression was introduced in the recent refactoring:
f8a21ab11b (diff-0175d58138b2e8b2bec087ffe0495340)
This commit is contained in:
Rossen Stoyanchev
2017-03-29 16:10:53 -04:00
parent a8162c03f9
commit d1db249584
6 changed files with 61 additions and 8 deletions

View File

@@ -181,7 +181,7 @@ public abstract class AbstractCodecConfigurer {
/**
* A registry and a factory for built-in HTTP message readers and writers.
*/
public static class DefaultCodecConfigurer {
public abstract static class DefaultCodecConfigurer {
private boolean suppressed = false;
@@ -280,13 +280,9 @@ public abstract class AbstractCodecConfigurer {
}
protected void addStringReaderTextOnlyTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly(true)));
}
protected abstract void addStringReaderTextOnlyTo(List<HttpMessageReader<?>> result);
protected void addStringReaderTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
}
protected abstract void addStringReaderTo(List<HttpMessageReader<?>> result);
protected void addStringWriterTextPlainOnlyTo(List<HttpMessageWriter<?>> result) {
addWriterTo(result, () -> new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly()));

View File

@@ -18,6 +18,7 @@ package org.springframework.http.codec;
import java.util.List;
import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
/**
@@ -79,6 +80,14 @@ public class ClientCodecConfigurer extends AbstractCodecConfigurer {
// Internal methods for building a list of default readers or writers...
protected void addStringReaderTextOnlyTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly(false)));
}
protected void addStringReaderTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(false)));
}
private void addServerSentEventReaderTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> findReader(ServerSentEventHttpMessageReader.class, () -> {
Decoder<?> decoder = null;

View File

@@ -18,6 +18,7 @@ package org.springframework.http.codec;
import java.util.List;
import org.springframework.core.codec.Encoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
/**
@@ -78,6 +79,14 @@ public class ServerCodecConfigurer extends AbstractCodecConfigurer {
// Internal methods for building a list of default readers or writers...
protected void addStringReaderTextOnlyTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly(true)));
}
protected void addStringReaderTo(List<HttpMessageReader<?>> result) {
addReaderTo(result, () -> new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes(true)));
}
private void addServerSentEventWriterTo(List<HttpMessageWriter<?>> result) {
addWriterTo(result, () -> findWriter(ServerSentEventHttpMessageWriter.class, () -> {
Encoder<?> encoder = null;