python - Gmail 是如何做到的?

标签 python ajax google-chrome google-app-engine gmail

我正在开发类似于 banatag 的服务。在新功能开发过程中,我发现了 Gmail 无法解释的行为(正如我所想)。

我将尝试在图片中解释我的问题:

  1. 创建标签(我将请求的图像)。现在没人要求了

  2. 通过 URL 将其添加到电子邮件中。图片地址http://eggplant-tag.appspot.com/request?FT1R3WECWNTM2ZGUDXRMA8VOXJ4F6TI4

  3. 页面有两个新的 AJAX 请求,但没有到我的域

  4. 寻找我的服务。有请求来 self 的 IP,使用 Google User-Agent

什么要求这张图片(标签)? 我看到两种可能性:

  • 页面向我的服务发出 AJAX 请求,这就是我看到我的 IP 的原因。但在这种情况下,为什么我在 Developer Console 的 Network 选项卡中看不到此请求?

  • Google Image Proxy 服务请求我的服务,但为什么在这种情况下请求中有我的 IP?

我的IP:

[更新] 将处理请求的类的一部分添加到 image(tag):

...
request.remoteAddress = str(self.request.remote_addr)# save remote address
request.put()
...
self.response.write(simpleImageData) #write to body binary data of 1x1 transparent image
self.response.headers[ 'Content-Type' ] = 'image/png'
self.response.headers[ 'Cache-Control' ] = 'no-cache, no-store, must-revalidate'
self.response.headers[ 'Pragma' ] = 'no-cache'
self.response.headers[ 'Expires' ] = '0'

[更新 2]

我使用 wireshark 找到了对我的服务的请求,但没有任何请求。这就是为什么主要问题是 Google 用户内容如何模拟我的 IP 地址?

最佳答案

Google Image Proxy 的工作原理已在网络上进行了彻底分析,例如 https://litmus.com/blog/gmail-adds-image-caching-what-you-need-to-knowhttps://blog.filippo.io/how-the-new-gmail-image-proxy-works-and-what-this-means-for-you/ -- googleusercontent 站点是 GIP 使用的缓存/cdn(除其他外)。

Google App Engine 的唯一相关性可能是您如何配置您没有向我们展示的 app.yaml,即该图像是作为静态文件提供的,还是通过逻辑提供的在您的应用程序代码中——如果是后者,您的代码在提供图像时是否有任何日志记录调用。根据您显示的有限数据,我猜想是前者(因此文件存在于 Google 的静态文件服务器上并由其提供服务,而不是在您自己的实例上的应用程序代码旁边),这将消除任何神秘感......

关于python - Gmail 是如何做到的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34770630/

相关文章:

python - 使用 Paramiko 时的环境变量差异

python - 在 python 中使用 nose 进行并行化测试

jquery - 如何格式化 url : for a jQuery ajax() request in CakePHP so it won't add a question mark to the url?

javascript - 有没有办法使用 :remote => true? 从 link_to 标记调用 Rails 3 函数

javascript - scrollIntoView() 在 Chrome 中的多个元素上使用平滑函数

python - SimpleXMLRPCServer、wxPython 和线程 - 如何停止?

python - 在 Python 中访问未知的查询参数

java - 你如何在 Spring MVC 中处理 Ajax 请求?

javascript - Chrome 扩展程序 - 奇怪的执行顺序

javascript - Chrome Web 检查器一次切换所有调试器点。