如果您使用 (&callback=) 向受 IP 地址限制速率的站点进行客户端 getJSON() 调用,那么他们会看到您的站点还是最终用户的站点?
如果您的网络应用使用网络服务 API 调用外部源,其中一些源将根据 IP 地址对您进行速率限制。
如果您从客户端 JavaScript 进行这些调用(这意味着它们是由最终用户的浏览器操作触发的)远程站点(发送回 JSON数据)查看您网站的 IP 地址或最终用户的 IP 地址 (为了实现基于 IP 地址的速率限制)?
我的理解是,通过在数据源URL中使用&callback=
,您将发出JSONP
请求,这意味着远程主机看到的地址是最终用户的地址,而不是您网站的地址。
例如:
jQuery.getJSON(url+"&callback=?", function(data) {
alert("Stock Symbol: " + data.symbol + ", Stock Price: " + data.price);
});
像上面这样的调用会被视为来自最终用户的 IP 地址而不是来自您的网络应用的服务器 IP 地址,这是否正确?
If your web app uses web service API calls to an external source, some of these sources will rate-limit you based on IP address.
If you make these calls from client-side JavaScript -- meaning that they are triggered by browser actions of the end user -- does the remote site (which sends back the JSON data) see your site's IP address or the IP address of the end-user
(for the purpose of this IP address-based rate limiting)?
My understanding is that by using &callback=
in the data source URL, you will issue a JSONP
request, which means that the address seen by the remote host is that of the end-user and not the address of your site.
For example:
jQuery.getJSON(url+"&callback=?", function(data) {
alert("Stock Symbol: " + data.symbol + ", Stock Price: " + data.price);
});
Is it correct that a call like the one above would be seen as coming from the end-user's IP address and not from your web app's server IP address?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
他们看到最终用户的 IP,JSONP 请求直接从用户的浏览器发送到它指向的 URL。通过进行 JSONP 调用,您基本上要做的就是将其添加到页面中:
这使得浏览器只需获取并运行该脚本,该脚本具有以下内容:
They see the end user's IP, a JSONP request goes straight from the user's browser to the URL it points to. What you're basically doing by making a JSONP call is adding this to the page:
This makes the browser just fetch and run that script, which has this content: