Reputation: 199
When I load certain urls in my javafx webview application I get this error
Error 403
Guru Meditation:
XID: 1087555431
Varnish cache server
The website loads fine in Chrome, firefox, etc. It would appear that this is an issue with webview. What is a work around?
URL that breaks is http://mp3skull.com
Upvotes: 0
Views: 371
Reputation: 159291
It is not a fault of WebView, it is some kind of setting on the target site (as suggested by James_D in comments). The target site is checking the user agent of the incoming request and responding with a weird Amiga emulated guru meditation error if it does not detect a recognized user agent.
To get around this, you can set the user agent of the WebView to masquerade as another browser (e.g. Chrome). I copied a user agent from useragentstring.com and when I used the Chrome user agent string the target web page opened fine without any guru mediation.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Pirate extends Application {
public static final String CHROME_41_USER_AGENT =
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
@Override
public void start(final Stage stage) throws Exception {
WebView webView = new WebView();
webView.getEngine().setUserAgent(
CHROME_41_USER_AGENT
);
webView.getEngine().load("http://mp3skull.com");
stage.setScene(new Scene(webView));
stage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
Upvotes: 1