简体   繁体   English

停止客户端中的 HTTP 请求

[英]Stop the HTTP request in Client

I have the scenario to the HTTP request which is hitted from the browser address bar and i need to redirect to different URL on the client side.我有从浏览器地址栏点击的 HTTP 请求的场景,我需要在客户端重定向到不同的 URL。

Is there any way to Abort the HTTP request and redirects to the new URL.有什么方法可以中止 HTTP 请求并重定向到新的 URL。

No, if you were able to do it, it would be a large vulnerability.不,如果你能做到,那将是一个很大的漏洞。 The reason being is that the http request would signify request headers being sent back to your browser, indicating that you're already on your way to the other site.原因是 http 请求将表示请求标头被发送回您的浏览器,表明您已经在前往另一个站点的路上。 If this could be done via javascript, it would definitely be a hack, as it would allow you to redirect a site such as fakebank.com instead of mybank.com .如果这可以通过 javascript 完成,那肯定是一个 hack,因为它允许您重定向诸如fakebank.com而不是mybank.com之类的站点。

You cannot do this using just javascript.您不能仅使用 javascript 来执行此操作。

You need to capture the request on the server side and make a 3XX request setting the Location http header to the URL you want to redirect your users to您需要在服务器端捕获请求并发出 3XX 请求,将Location http header 设置为 URL 您要将用户重定向到

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

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