Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static co.elastic.apm.agent.tracer.AbstractSpan.PRIORITY_HIGH_LEVEL_FRAMEWORK;
import static co.elastic.apm.agent.tracer.AbstractSpan.PRIORITY_LOW_LEVEL_FRAMEWORK;
Expand Down Expand Up @@ -313,13 +315,16 @@ private static void fillResponse(Transaction<?> transaction, ServerWebExchange e
}

private static void copyHeaders(HttpHeaders source, PotentiallyMultiValuedMap destination) {
for (Map.Entry<String, List<String>> header : source.entrySet()) {
// This is the only way I could find to make a multiValueMap without having access
// to the api from spring framework 7 that will work across versions 5, 6 and 7
Map<String, List<String>> multiValueHeaderMap = source.toSingleValueMap().keySet()
.parallelStream().collect(Collectors.toMap(e -> e, key -> Objects.requireNonNull(source.get(key))));
for (Map.Entry<String, List<String>> header : multiValueHeaderMap.entrySet()) {
for (String value : header.getValue()) {
destination.add(header.getKey(), value);
}
}
}

private static void copyCookies(MultiValueMap<String, HttpCookie> source, PotentiallyMultiValuedMap destination) {
for (Map.Entry<String, List<HttpCookie>> cookie : source.entrySet()) {
for (HttpCookie value : cookie.getValue()) {
Expand Down
Loading