Ensure that wrapped servlet requests have query parameters
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
@@ -71,6 +72,35 @@ public void addHeader(String name, String value) {
throw new UnsupportedOperationException("addHeader");
}
+ @Override
+ public String getQueryParameter(String name) {
+ String[] allValues = req.getParameterMap().get(name);
+ if (allValues == null || allValues.length == 0) {
+ return null;
+ }
+
+ return allValues[0];
+ }
+
+ @Override
+ public void addQueryParameter(String name, String value) {
+ throw new UnsupportedOperationException("addQueryParameter");
+ }
+
+ @Override
+ public Iterable<String> getQueryParameterNames() {
+ return req.getParameterMap().keySet();
+ }
+
+ @Override
+ public Iterable<String> getQueryParameters(String name) {
+ String[] allValues = req.getParameterMap().get(name);
+ if (allValues == null) {
+ return Collections.emptySet();
+ }
+ return () -> Arrays.stream(allValues).iterator();
+ }
+
@Override
public void setContent(byte[] data) {
throw new UnsupportedOperationException("setContent");
