简体   繁体   English

如何使用修改的User-Agent标头javascript或php进行跨源Http发布请求?

[英]How to make a cross origin Http post request with modified User-Agent header javascript or php?

I want to read plain/text from an Https server. 我想从Https服务器读取纯文本。 I have tried various codes php and JavaScripts, but to no success. 我尝试了各种代码php和JavaScript,但是没有成功。 I tried to send a request using Fiddle HTTP Debugging software with modified user-Agent value and I got a response from the server. 我尝试使用Fiddle HTTP调试软件以修改的user-Agent值发送请求,并收到服务器的响应。 When I used JavaScript, the browser Firefox and Chrome always change the user-Agent parameter to default agent. 当我使用JavaScript时,浏览器Firefox和Chrome始终将user-Agent参数更改为默认代理。 I never got anything from the server. 我从服务器什么都没收到。

-Send https POST to mydomain.code.com -User-Agent must be 'myAgent 1.0' -将https POST发送到mydomain.code.com-用户代理必须为“ myAgent 1.0”

NOTE: am sending the request from another domain. 注意:正在从另一个域发送请求。

What is the best approach for this? 最好的方法是什么? Please I need some help here! 请在这里我需要一些帮助! thanks in anticipation 谢谢你的期待

You won't be able to get around the cross domain restrictions (see same origin policy ), at least on the browser side. 至少在浏览器端,您将无法解决跨域限制(请参阅相同的原始策略 )。 You'll need to use a proxy of some sort. 您需要使用某种代理。 There is a good description along with sample code here . 有一个与示例代码的一个很好的说明这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM