|
|
|
@ -18,6 +18,7 @@ package org.springframework.http.codec.multipart; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.nio.channels.ReadableByteChannel; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.Duration; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
@ -44,6 +45,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
|
|
|
|
|
|
|
|
import static java.util.Collections.emptyMap; |
|
|
|
import static java.util.Collections.emptyMap; |
|
|
|
|
|
|
|
import static java.util.Collections.singletonMap; |
|
|
|
import static org.hamcrest.core.StringStartsWith.startsWith; |
|
|
|
import static org.hamcrest.core.StringStartsWith.startsWith; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
import static org.junit.Assert.assertFalse; |
|
|
|
@ -149,6 +151,24 @@ public class SynchronossPartHttpMessageReaderTests { |
|
|
|
subscriber.cancel(); |
|
|
|
subscriber.cancel(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void gh23768() throws IOException { |
|
|
|
|
|
|
|
ReadableByteChannel channel = new ClassPathResource("invalid.multipart", getClass()).readableChannel(); |
|
|
|
|
|
|
|
Flux<DataBuffer> body = DataBufferUtils.readByteChannel(() -> channel, this.bufferFactory, 1024); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MediaType contentType = new MediaType("multipart", "form-data", |
|
|
|
|
|
|
|
singletonMap("boundary", "NbjrKgjbsaMLdnMxMfDpD6myWomYc0qNX0w")); |
|
|
|
|
|
|
|
ServerHttpRequest request = MockServerHttpRequest.post("/") |
|
|
|
|
|
|
|
.contentType(contentType) |
|
|
|
|
|
|
|
.body(body); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mono<MultiValueMap<String, Part>> parts = this.reader.readMono(PARTS_ELEMENT_TYPE, request, emptyMap()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StepVerifier.create(parts) |
|
|
|
|
|
|
|
.assertNext(result -> assertThat(result).isEmpty()) |
|
|
|
|
|
|
|
.verifyComplete(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void readTooManyParts() { |
|
|
|
public void readTooManyParts() { |
|
|
|
testMultipartExceptions(reader -> reader.setMaxParts(1), ex -> { |
|
|
|
testMultipartExceptions(reader -> reader.setMaxParts(1), ex -> { |
|
|
|
|