Allow empty body with no content type in BodyExtractors

Issue: SPR-15758
This commit is contained in:
Rossen Stoyanchev
2017-07-14 14:38:42 +02:00
parent d2c6ea5b1b
commit 9d04c0424d
2 changed files with 28 additions and 4 deletions

View File

@@ -56,7 +56,9 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
/**
@@ -169,6 +171,17 @@ public class BodyExtractorsTests {
.verify();
}
@Test // SPR-15758
public void toMonoWithEmptyBodyAndNoContentType() throws Exception {
BodyExtractor<Mono<Map<String, String>>, ReactiveHttpInputMessage> extractor =
BodyExtractors.toMono(new ParameterizedTypeReference<Map<String, String>>() {});
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(Flux.empty());
Mono<Map<String, String>> result = extractor.extract(request, this.context);
StepVerifier.create(result).expectComplete().verify();
}
@Test
public void toFlux() throws Exception {
BodyExtractor<Flux<String>, ReactiveHttpInputMessage> extractor = BodyExtractors.toFlux(String.class);