So here is the scenario which we have/want to implement:
Here are the things which we implemented so far:
Issue Which we are facing:
Here is the code fragment for doing httpresponse modification task:
protected void copyResponseEntity(HttpResponse proxyResponse, HttpServletResponse servletResponse,
HttpRequest proxyRequest, HttpServletRequest servletRequest)throws IOException {
HttpEntity entity = new BufferedHttpEntity(proxyResponse.getEntity());
if (entity.isChunked()) {
InputStream is = entity.getContent();
String proxyBody = EntityUtils.toString(entity);
proxyBody = proxyBody.replaceAll("/.netContextRoot/", "/ourContextRoot/.netContextRoot/");
InputStream stream = new ByteArrayInputStream(proxyBody.getBytes(StandardCharsets.UTF_8));
OutputStream os = servletResponse.getOutputStream();
byte[] buffer = new byte[10 * 1024];
int read;
while ((read = stream.read(buffer)) != -1) {
os.write(buffer, 0, read);
if (doHandleCompression || stream.available() == 0 /* next is.read will block */) {
os.flush();
}
}
// Entity closing/cleanup is done in the caller (#service)
} else {
String proxyBody = EntityUtils.toString(entity);
proxyBody = proxyBody.replaceAll("/.netContextRoot/", "/ourContextRoot/.netContextRoot/");
EntityUtils.updateEntity(proxyResponse, new StringEntity(proxyBody));
HttpEntity entity2 = proxyResponse.getEntity();
OutputStream servletOutputStream = servletResponse.getOutputStream();
entity2.writeTo(servletOutputStream);
}
}
Can anybody help us out with this scenario, Also if you have any other solution without making any changes in apache level then pls do mention.
Thanks in Advance.
I finally found some answers to dodge PageRequestManagerParserErrorException.
Note:
a) You can use this link to achieve reverse proxy: As this has only code level change, so its very simple to achieve and also there is no server level config changes required.
b) PageRequestManagerParserErrorException occurs when you edit httpResponse before sending it to client and its triggered by eventValidation of .net.
c) 1st solution is useless if you are not allowed to make any change in the 3rd party application just like mine scenario. For time being I went with the 3rd one as it did the job without much effort.