Javafx webview http响应数据 [英] Javafx webview http response data
问题描述
是否可以从webview中加载的页面读取http请求和响应数据。我想要做的是在用户点击webview中页面内的链接后从响应中获取二进制数据。任何帮助或线索将不胜感激
Is it possible to read the http request and response data from pages loading inside webview. What i want to do is get the binary data from a response after user clicks on a link inside the page in webview. Any help or clue would be greatly appreciated
推荐答案
创建自己的 URLStreamHandlerFactory 由 URL.setURLStreamHandlerFactory 生成 URLStreamHandler ,它包装标准的http和https URLStreamHandlers,以便在转发之前拦截其流量。
Create your own URLStreamHandlerFactory initialized by URL.setURLStreamHandlerFactory which generates a URLStreamHandler that wraps the standard http and https URLStreamHandlers to intercept their traffic before forwarding.
Java协议处理程序的新时代白皮书。
另一个选择是收听 WebEngine.location 属性并打开一个到服务器的单独连接根据需要检索和处理二进制数据。这种方法的一个例子是 pdf处理柳树网络浏览器的代码。
Another option is to listen to the WebEngine.location property and open a separate connection to a server to retrieve and process the binary data as needed. An example of this approach is the pdf handling code for the willow web browser.
这篇关于Javafx webview http响应数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!