Setting “unsafe” headers in packaged app XHR

ぃ、小莉子 提交于 2019-12-04 04:00:41

问题


I need to modify the User-Agent header in an XHR request in my packaged app. When I do so, I get the error:

Refused to set unsafe header "User-Agent"

My app already has full socket access, so I could do it that way. But that would be really, really annoying.

It would be super nice if I were allowed to set this header in packaged apps that already have raw socket access.

Maybe there is some other API or permission that I'm not aware of? webRequest doesn't seem to be relevant here.


回答1:


It seems unlikely that this will be addressed on the Chrome platform. So when I need to have more control over my XMLHttpRequest, I use my own shim, which I am keeping up to date inside the Web Server for Chrome (github) project. You can see it being used in this example



来源:https://stackoverflow.com/questions/21105471/setting-unsafe-headers-in-packaged-app-xhr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!