Add formData() and multipartData() to ServerRequest

Issue: SPR-16551
This commit is contained in:
Arjen Poutsma
2018-03-23 09:58:59 +01:00
parent 1b83f129a2
commit c56317928f
7 changed files with 160 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRange;
import org.springframework.http.HttpRequest;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.Part;
import org.springframework.http.server.PathContainer;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.reactive.ServerHttpRequest;
@@ -209,6 +210,21 @@ public class MockServerRequest implements ServerRequest {
return Mono.justOrEmpty(this.principal);
}
@Override
@SuppressWarnings("unchecked")
public Mono<MultiValueMap<String, String>> formData() {
Assert.state(this.body != null, "No body");
return (Mono<MultiValueMap<String, String>>) this.body;
}
@Override
@SuppressWarnings("unchecked")
public Mono<MultiValueMap<String, Part>> multipartData() {
Assert.state(this.body != null, "No body");
return (Mono<MultiValueMap<String, Part>>) this.body;
}
public static Builder builder() {
return new BuilderImpl();
}