如何拦截和修改来自 WebView (Mac) 的 HTTP 响应?
我想拦截来自 HTTP 请求的资源响应,该请求是从当前正在加载的页面作为附加资源下载的。我特别尝试对来自正在请求的 iframe 的 JavaScript 文件执行此操作,然后再将其从响应加载到内存中。这意味着我无法从 Web 视图执行 JavaScript 来直接修改 iframe
中的 DOM。
一旦被拦截,我想附上我自己的逻辑。这是一种经典的中间人攻击,只不过我在将请求渲染到 Web 视图之前附加了自己的逻辑。
现在我正盯着 WebResourceLoadDelegate
协议,但我找不到任何允许我修改传入响应的文档。
I would like to intercept a resource response from an HTTP request that is downloaded as an additional resource from a page that is currently being loaded. I am specifically trying to do this to a JavaScript file from an iframe
that is being requested, before it is loaded into memory from the response. This means that I cannot execute JavaScript from the web view to directly modify the DOM in the iframe
.
Once intercepted, I would like to attach my own logic to it. This is a classic man-in-the-middle attack, except that I am attaching my own logic to it before rendering the request into the web view.
Right now I am staring at the WebResourceLoadDelegate
protocol but I cannot find any documentation that leads to allowing me modify the incoming response.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论