10

How to pass the HTTP Headers like

"Accept-Language", "Accept", "Accept-Encoding" to WebEngine in JavaFX? i have tried the method as specified in Setting a cookie using JavaFX's WebEngine/WebView, but it doesn't work. is there any API that is being exposed in Java 8 for achieving this? Pls suggest.

Community
  • 1
  • 1
Arun
  • 111
  • 1
  • 4
  • Your question is possible duplicate, see answer here: http://stackoverflow.com/questions/13803480/useragent-implement-method-on-javafx-webengine – janih Sep 22 '14 at 11:23
  • Thanks @janih - Still there're no docs or links to specify how to set http headers other than User-Agent. Has that been made possible with JavaFX 8? I browsed through the [link](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebEngine.html) , but couldn't find any relevant methods. – Arun Sep 29 '14 at 11:09
  • you are right, it doesn't seem to be possible to set other headers than user agent. However, it might be possible to set the http headers by implementing [a custom protocol handler](http://stackoverflow.com/questions/17522343/custom-javafx-webview-protocol-handler) – janih Sep 30 '14 at 20:42
  • Actually the only way i found, was it: https://twitter.com/CodingFabian/status/524942996748652544 – William May 08 '18 at 17:30
  • look:https://stackoverflow.com/questions/36917469/how-can-i-work-around-youtube-api-embed-restrictions-like-other-websites?answertab=active#tab-top – 远星河 Nov 02 '19 at 05:17

1 Answers1

2

Since JDK 8u60 the default locale of the application is automatically added to the "Accept-Language" header as the first option. This may help in some cases although it would of course be better to be able to set all these headers explicitly.

mipa
  • 10,369
  • 2
  • 16
  • 35