@@ -324,30 +324,28 @@ private static class DelegatingServerWebExchange implements ServerWebExchange {
324
324
325
325
private final Mono <MultiValueMap <String , Part >> multipartDataMono ;
326
326
327
- private volatile boolean multipartRead = false ;
328
-
329
-
330
327
DelegatingServerWebExchange (ServerHttpRequest request , Map <String , Object > attributes ,
331
328
ServerWebExchange delegate , List <HttpMessageReader <?>> messageReaders ) {
332
329
333
330
this .request = request ;
334
331
this .attributes = attributes ;
335
332
this .delegate = delegate ;
336
- this .formDataMono = initFormData (messageReaders );
333
+ this .formDataMono = initFormData (request , messageReaders );
337
334
this .multipartDataMono = initMultipartData (request , messageReaders );
338
335
}
339
336
340
337
@ SuppressWarnings ("unchecked" )
341
- private Mono <MultiValueMap <String , String >> initFormData (List <HttpMessageReader <?>> readers ) {
338
+ private static Mono <MultiValueMap <String , String >> initFormData (ServerHttpRequest request ,
339
+ List <HttpMessageReader <?>> readers ) {
340
+
342
341
try {
343
- MediaType contentType = this . request .getHeaders ().getContentType ();
342
+ MediaType contentType = request .getHeaders ().getContentType ();
344
343
if (MediaType .APPLICATION_FORM_URLENCODED .isCompatibleWith (contentType )) {
345
344
return ((HttpMessageReader <MultiValueMap <String , String >>) readers .stream ()
346
345
.filter (reader -> reader .canRead (FORM_DATA_TYPE , MediaType .APPLICATION_FORM_URLENCODED ))
347
346
.findFirst ()
348
347
.orElseThrow (() -> new IllegalStateException ("No form data HttpMessageReader." )))
349
- .readMono (FORM_DATA_TYPE , this .request , Hints .none ())
350
- .doOnNext (ignored -> this .multipartRead = true )
348
+ .readMono (FORM_DATA_TYPE , request , Hints .none ())
351
349
.switchIfEmpty (EMPTY_FORM_DATA )
352
350
.cache ();
353
351
}
@@ -400,23 +398,7 @@ public Mono<MultiValueMap<String, Part>> getMultipartData() {
400
398
return this .multipartDataMono ;
401
399
}
402
400
403
- @ Override
404
- public Mono <Void > cleanupMultipart () {
405
- if (this .multipartRead ) {
406
- return getMultipartData ()
407
- .onErrorResume (t -> Mono .empty ()) // ignore errors reading multipart data
408
- .flatMapIterable (Map ::values )
409
- .flatMapIterable (Function .identity ())
410
- .flatMap (part -> part .delete ()
411
- .onErrorResume (ex -> Mono .empty ()))
412
- .then ();
413
- }
414
- else {
415
- return Mono .empty ();
416
- }
417
- }
418
-
419
- // Delegating methods
401
+ // Delegating methods
420
402
421
403
@ Override
422
404
public ServerHttpResponse getResponse () {
0 commit comments