fix: combine the form map and queryParams to pass to RequestWrapper (#3249)

* fix: combine the form map and queryParams to pass to RequestWrapper

Fixes #3244
This commit is contained in:
Lulu
2024-03-08 23:44:29 +08:00
committed by GitHub
parent df6269ef5c
commit 12fa425ef2

View File

@@ -24,6 +24,7 @@ import java.io.Writer;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
@@ -48,6 +49,7 @@ import org.springframework.core.Ordered;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;
@@ -151,9 +153,15 @@ public class FormFilter implements Filter, Ordered {
}
writer.flush();
MultiValueMap<String, String> combineQueryParams = new LinkedMultiValueMap<>();
for (Map.Entry<String, String[]> entry : form.entrySet()) {
combineQueryParams.put(entry.getKey(), new ArrayList<>(Arrays.asList(entry.getValue())));
}
combineQueryParams.addAll(queryParams);
ByteArrayServletInputStream servletInputStream = new ByteArrayServletInputStream(
new ByteArrayInputStream(bos.toByteArray()));
return new FormContentRequestWrapper(request, queryParams) {
return new FormContentRequestWrapper(request, combineQueryParams) {
@Override
public ServletInputStream getInputStream() throws IOException {
return servletInputStream;