知道HTTP请求是否来自Chrome URL自动完成? [英] Know if HTTP request is from Chrome URL auto-complete?

查看:149
本文介绍了知道HTTP请求是否来自Chrome URL自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个响应 GET / logout 的Web应用程序,并删除您的会话Cookie。如果您开始在网址列中输入任何其他含有 / l 的网址,Chrome会自动建议 / logout 。当它这样做时,它会请求 / logout 预取内容。我的HTTP服务器如何知道请求是否来自这种预取行为?

$ / $>

b
$ b

我试过的:


  • 检查请求标头的唯一性。我没有看到预取请求中的任何内容。

  • 使用'Cache-Control':'no-cache,no-store'告诉浏览器不缓存来自 GET / logout


解决方案

将您的注销更改为使用POST而不是GET。


We have a web application that responds to GET /logout and deletes your session cookies. If you start typing any other URL that beings with /l into the URL bar, Chrome will auto-suggest /logout. When it does this, it makes a request to /logout to pre-fetch the content. The result is that the user is un-expectedly logged out.

How can my HTTP server know if a request is from this pre-fetch behavior?

What I've tried:

  • Inspecting the request headers for something unique. I do not see anything unique from the pre-fetch request.
  • Using 'Cache-Control': 'no-cache, no-store' to tell the browser to not cache the response from GET /logout

解决方案

Change your logout to use POST instead of GET.

这篇关于知道HTTP请求是否来自Chrome URL自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆