final String scriptName = requestSettings.getUrl().toString();
final String scriptSource = response.getContentAsString();
// skip if it is already formatted? => TODO
final ContextFactory factory = new ContextFactory();
final ContextAction action = new ContextAction() {
public Object run(final Context cx) {
cx.setOptimizationLevel(-1);
final Script script = cx.compileString(scriptSource, scriptName, 0, null);
return cx.decompileScript(script, 4);
}
};
try {
final String decompileScript = (String) factory.call(action);
final WebResponseData wrd = new WebResponseData(decompileScript.getBytes(), response.getStatusCode(),
response.getStatusMessage(), response.getResponseHeaders());
return new WebResponseImpl(wrd, response.getRequestSettings().getUrl(),
response.getRequestSettings().getHttpMethod(), response.getLoadTime());
}