Google.com 和clients1.google.com/generate_204

发布于 2024-08-16 04:49:11 字数 1281 浏览 2 评论 0原文

我正在调查 google.com 在 firebug 中的网络活动,只是因为我很好奇,并注意到一个请求返回“204 无内容”。

事实证明,204 No Content“主要是为了允许输入要发生的操作,而不会导致用户代理的活动文档视图发生更改,尽管任何新的或更新的元信息应该应用于当前在用户代理的活动文档视图中看法。”任何。

我查看了 JS 源代码,发现“generate_204”是这样请求的:

(new Image).src="http://clients1.google.com/generate_204"

根本没有变量声明/赋值。

我的第一个想法是它被用来跟踪 Javascript 是否启用。但无论如何,“(new Image).src='...'”调用是从动态加载的外部 JS 文件中调用的,因此这是毫无意义的。

有人对重点是什么有任何想法吗?

更新

“/generate_204”似乎可在许多 Google 服务/服务器上使用(例如,maps.google.com/generate_204、maps.gstatic.com/generate_204 等)。

您可以通过为您的网络应用程序可能使用的每个 Google 拥有的服务预获取generate_204 页面来利用这一点。像这样:

window.onload = function(){
    var two_o_fours = [
        // google maps domain ...
        "http://maps.google.com/generate_204",

        // google maps images domains ... 
        "http://mt0.google.com/generate_204",
        "http://mt1.google.com/generate_204",
        "http://mt2.google.com/generate_204",
        "http://mt3.google.com/generate_204",

        // you can add your own 204 page for your subdomains too!
        "http://sub.domain.com/generate_204"
    ];
    for(var i = 0, l = two_o_fours.length; i < l; ++i){
        (new Image).src = two_o_fours[i];
    }
};

I was looking into google.com's Net activity in firebug just because I was curious and noticed a request was returning "204 No Content."

It turns out that a 204 No Content "is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view." Whatever.

I've looked into the JS source code and saw that "generate_204" is requested like this:

(new Image).src="http://clients1.google.com/generate_204"

No variable declaration/assignment at all.

My first idea is that it was being used to track if Javascript is enabled. But the "(new Image).src='...'" call is called from a dynamically loaded external JS file anyway, so that would be pointless.

Anyone have any ideas as to what the point could be?

UPDATE

"/generate_204" appears to be available on many google services/servers (e.g., maps.google.com/generate_204, maps.gstatic.com/generate_204, etc...).

You can take advantage of this by pre-fetching the generate_204 pages for each google-owned service your web app may use. Like This:

window.onload = function(){
    var two_o_fours = [
        // google maps domain ...
        "http://maps.google.com/generate_204",

        // google maps images domains ... 
        "http://mt0.google.com/generate_204",
        "http://mt1.google.com/generate_204",
        "http://mt2.google.com/generate_204",
        "http://mt3.google.com/generate_204",

        // you can add your own 204 page for your subdomains too!
        "http://sub.domain.com/generate_204"
    ];
    for(var i = 0, l = two_o_fours.length; i < l; ++i){
        (new Image).src = two_o_fours[i];
    }
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

你又不是我 2024-08-23 04:49:11

我在谷歌搜索generate_204时发现了这个旧线程,因为Android似乎使用它来确定wlan是否打开(收到响应204)关闭(根本没有响应)或阻止(存在重定向到强制门户)。在这种情况下,会显示一条通知,要求登录 WiFi...在此处输入图像描述

I found this old Thread while google'ing for generate_204 as Android seems to use this to determine if the wlan is open (response 204 is received) closed (no response at all) or blocked (redirect to captive portal is present). In that case a notification is shown that a log-in to WiFi is required...enter image description here

滥情空心 2024-08-23 04:49:11

正如 Snukker 所说,clients1.google.com 是搜索建议的来源。我的猜测是,他们会在您需要之前发出请求,强制 client1.google.com 进入您的 DNS 缓存,因此您在第一个“真实”请求上的延迟会更短。

谷歌浏览器已经对页面上的任何链接以及(我认为)当您在地址栏中键入地址时执行了此操作。这似乎是让所有浏览器做同样事情的一种方法。

Like Snukker said, clients1.google.com is where the search suggestions come from. My guess is that they make a request to force clients1.google.com into your DNS cache before you need it, so you will have less latency on the first "real" request.

Google Chrome already does that for any links on a page, and (I think) when you type an address in the location bar. This seems like a way to get all browsers to do the same thing.

千仐 2024-08-23 04:49:11

如果 Chrome 检测到 SSL 连接超时,证书
错误或其他可能由俘虏引起的网络问题
门户(例如酒店的 WiFi 网络),Chrome 将创建一个
http://www.gstatic.com/generate_204 发出无 cookie 请求并检查
响应代码。如果该请求被重定向,Chrome 将打开
假设它是登录页面,则在新选项卡中重定向目标。
不会记录对强制网络门户检测页面的请求。

来源:Google Chrome 隐私白皮书

In the event that Chrome detects SSL connection timeouts, certificate
errors, or other network issues that might be caused by a captive
portal (a hotel's WiFi network, for instance), Chrome will make a
cookieless request to http://www.gstatic.com/generate_204 and check
the response code. If that request is redirected, Chrome will open the
redirect target in a new tab on the assumption that it's a login page.
Requests to the captive portal detection page are not logged.

Source: Google Chrome Privacy Whitepaper

開玄 2024-08-23 04:49:11

谷歌正在使用它来检测设备是否在线或在强制门户中。

Shill 是 Chromium 操作系统的连接管理器,每当服务转换到就绪状态时,都会尝试检测强制门户内的服务。通过尝试检索网页 http://clients3.google 来确定处于强制门户中还是在线。 com/generate_204。这个众所周知的 URL 会返回一个 HTTP 状态为 204 的空页面。如果由于任何原因未返回该网页,或者收到除 204 之外的 HTTP 响应,则 shill 会将服务标记为处于门户状态。

以下是 Google Chrome 隐私白皮书中的相关说明:

如果 Chrome 检测到 SSL 连接超时、证书错误或其他可能由强制门户(例如酒店的 WiFi 网络)引起的网络问题,Chrome 将向 http://www.gstatic.com/generate_204 并检查响应代码。如果该请求被重定向,Chrome 将在新选项卡中打开重定向目标(假设它是登录页面)。不会记录对强制网络门户检测页面的请求。

更多信息:http://www.chromium.org/ chromium-os/chromiumos-design-docs/network-portal-detection

Google is using this to detect whether the device is online or in captive portal.

Shill, the connection manager for Chromium OS, attempts to detect services that are within a captive portal whenever a service transitions to the ready state. This determination of being in a captive portal or being online is done by attempting to retrieve the webpage http://clients3.google.com/generate_204. This well known URL is known to return an empty page with an HTTP status 204. If for any reason the web page is not returned, or an HTTP response other than 204 is received, then shill marks the service as being in the portal state.

Here is the relevant explanation from the Google Chrome Privacy Whitepaper:

In the event that Chrome detects SSL connection timeouts, certificate errors, or other network issues that might be caused by a captive portal (a hotel's WiFi network, for instance), Chrome will make a cookieless request to http://www.gstatic.com/generate_204 and check the response code. If that request is redirected, Chrome will open the redirect target in a new tab on the assumption that it's a login page. Requests to the captive portal detection page are not logged.

More info: http://www.chromium.org/chromium-os/chromiumos-design-docs/network-portal-detection

煮茶煮酒煮时光 2024-08-23 04:49:11

204 响应有时在 AJAX 中用于跟踪点击和页面活动。在这种情况下,在 get 请求中传递到服务器的唯一信息是 cookie,而不是请求参数中的特定信息,因此这里的情况似乎并非如此。

看来clients1.google.com是谷歌搜索建议背后的服务器。当您访问 http://www.google.com 时,Cookie 会传递到 http://clients1.google.com/generate_204。也许这是为了在服务器上启动某种会话?无论用途如何,我怀疑这是否是非常标准的用途。

204 responses are sometimes used in AJAX to track clicks and page activity. In this case, the only information being passed to the server in the get request is a cookie and not specific information in request parameters, so this doesn't seem to be the case here.

It seems that clients1.google.com is the server behind google search suggestions. When you visit http://www.google.com, the cookie is passed to http://clients1.google.com/generate_204. Perhaps this is to start up some kind of session on the server? Whatever the use, I doubt it's a very standard use.

忆沫 2024-08-23 04:49:11

随着谷歌投入大量资金来阻止垃圾邮件和搜索数据库的抓取,我相信这是跟踪机器人等工作的一部分。

一些简单的反机器人伪程序可能会像这样。

On GET (google.*) Save RemoteEndPoint
{
    If RemoteEndPoint GETs (clients1.google.com/generate_204) Then
        Set botAlert_stage1 = false;
    Else
        Set botAlert_stage1 = true;
    End If
}

我还相信最新的谷歌首页“主题”也是一个帮助反垃圾邮件/机器人活动的新工具。

** 注意 ** ipv6.google.com 也包含此措施。

只是我毫无根据、毫无证据的两个2p。

with the massive remit by google to stop both spam and the scraping of their search database, I believe that this is part of the effort to track bots etc.

some simple anti bot pseudo could go like this.

On GET (google.*) Save RemoteEndPoint
{
    If RemoteEndPoint GETs (clients1.google.com/generate_204) Then
        Set botAlert_stage1 = false;
    Else
        Set botAlert_stage1 = true;
    End If
}

I also believe that the latest google frontpage 'theme' is also a new tool to help with the anti spam/bot activity.

** NOTE ** ipv6.google.com also includes this measure.

Just my unfounded unproofed two 2p.

旧时光的容颜 2024-08-23 04:49:11

许多应用程序访问此 URL 以确定它们是否具有仅通向强制门户的连接。

这个想法是,任何强制门户网站都认为这是一个“正常”网站,然后将您重定向到其门户网站,该网站返回状态为 200。如果应用程序尝试访问任何正常网站,它会遇到完全意想不到的情况。响应,并且可能无法找出问题所在。但是,使用此 URL 很容易:如果您获得状态 200,则表明您处于强制门户内,您可以告诉您的用户对此执行某些操作(通常使用浏览器登录到门户,或者关闭 WiFi 并依赖3G(如果他们使用手机)。如果您获得状态 204,则表示您已连接到 Google,因此您的应用程序实际上已连接到互联网。

微软和苹果使用的方法略有不同。它们都有一些 URL 会返回状态为 200 的非常具体的短文本消息,因此您可以访问“captive.apple.com”并使用 data =“Success”检查状态 200,而不是访问 Google url没有别的。如果您获得状态 200,但不完全是该数据,那么您再次处于强制门户中。

Many applications access this URL to determine if they have a connection that only leads to a captive portal.

The idea is that any captive portal thinks this is a "normal" website, and then redirects you to its portal site, which is returned with a status 200. If an application tries to access any normal website, it is confronted with a totally unexpected response and may have problems figuring out what's wrong. However, with this URL it's easy: If you get status 200, you are inside a captive portal, and you can tell your user to do something about it (usually either log in to the portal using a browser, or turn WiFi off and rely on 3G, if they are using a phone). If you get status 204, you got connected to Google, so your application is actually connected to the internet.

Microsoft and Apple use a slightly different approach; they both have some URLs that return a very specific short text message with a status 200, so instead of accessing the Google url you can for example go to "captive.apple.com" and check for status 200 with data = "Success" and nothing else. If you get status 200 and not exactly that data then you are again in a captive portal.

橙味迷妹 2024-08-23 04:49:11

本文档解释:

http: //docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1417&context=ecetr&sei-redir=1

搜索generate204

相关部分:

在不同的对象中,JavaScript 函数会触发发送到应该提供视频服务的视频服务器的 generate204 请求。这会启动视频预取,它有两个主要目标:首先,它强制客户端执行视频服务器名称的 DNS 解析。其次,它强制客户端打开与视频服务器的 TCP 连接。两者都有助于加快视频下载阶段。

此外,generate204请求与真实视频下载请求具有完全相同的格式和选项,因此视频服务器最终会收到警告,客户端可能很快就会下载该视频。请注意,视频服务器会回复 204 No Content 响应,正如命令所暗示的那样,并且到目前为止还没有下载任何视频内容。

This documents explains:

http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1417&context=ecetr&sei-redir=1

(Search for generate204)

Relevant section:

Among the different objects, a javascript function triggers a generate204 request sent to the video server that is supposed to serve the video. This starts the video prefetch, which has two main goals: first, it forces the client to perform the DNS resolution of the video server name. Second, it forces the client to open a TCP connection toward the video server. Both help to speed-up the video download phase.

In addition, the generate204 request has exactly the same format and options of the real video download request, so that the video server is eventually warned that a client will possibly download that video very soon. Note that the video server replies with a 204 No Content response, as implied by the command, and no video content is downloaded so far.

温柔一刀 2024-08-23 04:49:11

我发现这篇博文解释了它是用来记录点击的。如果没有谷歌的官方消息,它可以用于多种用途。

http://mark.koli.ch/2009/03/howto-configure-apache-to-return-a-http-204-no-content-for-ajax.html

I found this blog post which explains that it's used to record clicks. Without official word from Google it could be used any number of things.

http://mark.koli.ch/2009/03/howto-configure-apache-to-return-a-http-204-no-content-for-ajax.html

风透绣罗衣 2024-08-23 04:49:11

生成器204可以动态加载搜索标准的建议。正如我从负载测试脚本中看到的那样,这似乎负责每次用户在文本框中键入内容时的每个服务器调用

The generate 204 might be dynamically loading the suggestions of search criteria. AS i can see from my load test script, this is seemingly responsible for every server call each time the user types into the text box

暖伴 2024-08-23 04:49:11

嗯,我已经看了好几次了,结果谷歌记录了他们第一次访问 google.com 的地方;使用 Google Chrome 进行跟踪,我有 90% 的猜测是用于记录引用者,也许当 Google 发布其浏览器使用标准列表时众所周知用户代理统计信息

响应标头

  • 内容长度:0
  • 内容类型:text/html
  • 日期:2010 年 5 月 21 日星期五 17:06:24 GMT
  • 服务器:GFE/2.0

这里“^请求标头”下的“Referer”显示了许多人来自的 Google 统计信息Microsoft.com,还解析出“Windows 7”一词来帮助我在我的后续搜索中重点关注 Windows 7 该会话

//Steven

Well i have been looking at this for a few times and resulted that Google logs referer's where they come from first time visiting the google.com for ex; tracking with Google Chrome i have a 90% guess that its for Logging Referers, maybe User-Agent statistics well known when Google release its list of standards of browser usage:

Response Headers

  • Content-Length: 0
  • Content-Type: text/html
  • Date: Fri, 21 May 2010 17:06:24 GMT
  • Server: GFE/2.0

Here "Referer" under "^Request Headers" shows Googles statistics that many folks come from Microsoft.com, also parsing out the word "Windows 7" to help me focus on Windows 7 in my up-following searches that session

//Steven

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文