问题
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