From 3bab57a379b1173cfdf9dc24913adf5d9f4fdcae Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Wed, 4 Apr 2018 18:47:49 +0200 Subject: add Request#getHeaders and #getParams() --- .../main/java/org/sonar/server/ws/ServletRequest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server') diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/ServletRequest.java b/server/sonar-server/src/main/java/org/sonar/server/ws/ServletRequest.java index 4393dcc0e65..a5ca06d166b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/ServletRequest.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/ServletRequest.java @@ -25,6 +25,7 @@ import com.google.common.net.HttpHeaders; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.util.Enumeration; import java.util.List; import java.util.Map; import java.util.Optional; @@ -152,4 +153,20 @@ public class ServletRequest extends ValidatingRequest { public Optional header(String name) { return Optional.ofNullable(source.getHeader(name)); } + + @Override + public Map getHeaders() { + ImmutableMap.Builder mapBuilder = ImmutableMap.builder(); + Enumeration headerNames = source.getHeaderNames(); + while (headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + mapBuilder.put(headerName, source.getHeader(headerName)); + } + return mapBuilder.build(); + } + + @Override + public Map getParams() { + return source.getParameterMap(); + } } -- cgit v1.2.3