I am trying to intercept a WebResource request from webview, make the request in the app and then return the response back with extra headers. However it is not working. The only two headers that are set are content-type and content-length. These two headers have correct values but no other extra headers are set. Not even using the newer WebResourceResponse
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
String url = request.getUrl().toString();
if (url.contains(2_DOMAIN)) {
if(url.contains("yesintercept")) {
String gresponse = makeGetRequest(url);
Map<String, String> responseHeaders = new HashMap<>();
responseHeaders.put("Access-Control-Allow-Origin", "*");
WebResourceResponse response = new WebResourceResponse("application/vnd.apple.mpegurl", "utf-8",new ByteArrayInputStream(gresponse.getBytes()));
response.setResponseHeaders(responseHeaders);
return response;
}
else {
return super.shouldInterceptRequest(view, request);
}
}
else {
return super.shouldInterceptRequest(view, request);
}
}