fix parameter/multimap handling with duplicates

This commit is contained in:
Jörg Prante 2023-12-21 15:52:55 +01:00
parent 0a31fca8fe
commit 41cca5c606

View file

@ -94,12 +94,12 @@ public abstract class BaseHttpRequestBuilder implements HttpRequestBuilder {
setHeaders(httpHeaders); setHeaders(httpHeaders);
setRequestURI(Maps.getString(map, "requesturi")); setRequestURI(Maps.getString(map, "requesturi"));
setRequestPath(Maps.getString(map, "requestpath")); setRequestPath(Maps.getString(map, "requestpath"));
ParameterBuilder parameterBuilder = Parameter.builder().domain(Parameter.Domain.QUERY); ParameterBuilder parameterBuilder = Parameter.builder().domain(Parameter.Domain.QUERY).enableDuplicates();
Map<String, Object> parameterMap = (Map<String, Object>) map.get("parameter"); Map<String, Object> parameterMap = (Map<String, Object>) map.get("parameter");
Arrays.asList(Parameter.Domain.QUERY, Parameter.Domain.PATH, Parameter.Domain.FORM, Parameter.Domain.COOKIE, Parameter.Domain.HEADER).forEach(d -> { Arrays.asList(Parameter.Domain.QUERY, Parameter.Domain.PATH, Parameter.Domain.FORM, Parameter.Domain.COOKIE, Parameter.Domain.HEADER).forEach(d -> {
Map<String, Object> m = (Map<String, Object>) parameterMap.get(d.name().toLowerCase(Locale.ROOT)); Map<String, Object> m = (Map<String, Object>) parameterMap.get(d.name().toLowerCase(Locale.ROOT));
if (m != null) { if (m != null) {
ParameterBuilder p = Parameter.builder().domain(d); ParameterBuilder p = Parameter.builder().domain(d).enableDuplicates();
m.forEach(p::add); m.forEach(p::add);
parameterBuilder.add(p.build()); parameterBuilder.add(p.build());
} }
@ -195,6 +195,7 @@ public abstract class BaseHttpRequestBuilder implements HttpRequestBuilder {
return byteBuffer; return byteBuffer;
} }
@Override
public CharBuffer getBodyAsChars(Charset charset) { public CharBuffer getBodyAsChars(Charset charset) {
if (charBuffer == null) { if (charBuffer == null) {
charBuffer = byteBuffer != null ? charset.decode(byteBuffer) : null; charBuffer = byteBuffer != null ? charset.decode(byteBuffer) : null;