Fix multi-part form handling for WebFlux apps

In WebFlux (but not MVC) you have to explicitly ask for the multi-
part content separately from the form data.

Fixes gh-223
This commit is contained in:
Dave Syer
2018-10-26 09:53:17 +01:00
parent a735f50daa
commit bf9ab3ac0a
4 changed files with 43 additions and 5 deletions

View File

@@ -302,7 +302,6 @@ public class HttpPostIntegrationTests {
}
@Test
@Ignore
public void multipart() throws Exception {
LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>();

View File

@@ -307,6 +307,20 @@ public class HttpPostIntegrationTests {
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
}
@Test
public void multipart() throws Exception {
LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.put("A", Arrays.asList("1", "2", "3"));
map.put("B", Arrays.asList("5", "6"));
assertThat(rest.exchange(
RequestEntity.post(new URI("/sum")).accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.MULTIPART_FORM_DATA).body(map),
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
}
@Test
public void count() throws Exception {
List<String> list = Arrays.asList("A", "B", "A");