Skip to content

Commit

Permalink
[INJIMOB-857] - access parameter map in overridden servel request wra…
Browse files Browse the repository at this point in the history
…pper

Signed-off-by: Swati Goel <[email protected]>
  • Loading branch information
swatigoel committed Jul 18, 2024
1 parent e72e1c8 commit 1f4bbba
Showing 1 changed file with 9 additions and 3 deletions.
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;
}
}

0 comments on commit 1f4bbba

Please sign in to comment.