Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INJIMOB-857] - access parameter map in overridden servlet request wrapper #1543

Closed
wants to merge 1 commit into from
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 @@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;

import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
Expand All @@ -20,9 +21,11 @@
*/
public class MultipleReadHttpRequest extends HttpServletRequestWrapper {
private byte[] cachedBody;
private Map<String, String[]> parameterMap;
public MultipleReadHttpRequest(HttpServletRequest request) throws IOException {
super(request);
InputStream requestInputStream = request.getInputStream();
parameterMap = request.getParameterMap();
InputStream requestInputStream = request.getInputStream();
this.cachedBody = StreamUtils.copyToByteArray(requestInputStream);
}

Expand All @@ -31,11 +34,14 @@ public ServletInputStream getInputStream() throws IOException {
return new MultipleReadServletInputStream(this.cachedBody);
}



@Override
public BufferedReader getReader() throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.cachedBody);
return new BufferedReader(new InputStreamReader(byteArrayInputStream));
}

@Override
public Map<String, String[]> getParameterMap() {
return this.parameterMap;
}
}
Loading