I’m trying to dig into how Gmail manages its real-time messaging through Comet. Using a network analysis tool, I examined the HTTP traffic while chatting in Gmail.
To do this, I logged into Gmail with two different accounts using Internet Explorer and Firefox. During a chat in Google Talk, I used the phrase “WASSUP” and then logged out of both accounts. By filtering the HTTP requests that did not contain the string “WASSUP”, I was able to identify which requests were related to the streaming channel.
The streaming URL seemed to resemble something like:
https://mail/channel/bind?VER=8&at=xn3j33vcvk39lkfq
It’s clear that Gmail’s Comet implementation in Internet Explorer utilizes an IFRAME. The content starts with HTML tags like <html><body>.
I had assumed Gmail would leverage multipart XmlHttpRequest in Firefox, but surprisingly, the response didn’t have the multipart/x-mixed-replace header. The headers were:
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Sat, 20 Mar 2010 01:52:39 GMT
X-Frame-Options: ALLOWALL
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
Server: GSE
X-XSS-Protection: 0
Unfortunately, the network tool didn’t confirm if the requests were made via XmlHttpRequest. The data returned was in JSON format, which suggests it could be related to XHR. However, I’m not sure how this can work for Comet without the necessary multipart headers.
Is there another method to analyze how Gmail implements Comet dynamics? I’m especially interested in how it differs across browsers.