WebSocketリクエストのヘッダ

なんとなくWebSocket APIの動作が思った通りにならなかったので、各種ブラウザのWebSocket接続リクエストのHeaderを調査しました。

このサイトではCookieを使ってないのでヘッダにCookieでてませんが、使っていれば普通にCookieが出力されます。

あと、Herokuのルータが付けてるヘッダ(x-forwarded-forなど)はカットしました。

★Chrome
cache-control: no-cache  
connect-time: 4  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
pragma: no-cache  
sec-websocket-extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 1  
upgrade: websocket  
user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36  
via: 1.1 vegur  

★Firefox
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
accept-encoding: gzip, deflate  
accept-language: ja,en-us;q=0.7,en;q=0.3  
cache-control: no-cache  
connect-time: 2  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
pragma: no-cache  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 0  
upgrade: websocket  
user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0  
via: 1.1 vegur  

★IE11
cache-control: no-cache  
connect-time: 1  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 0  
upgrade: Websocket  
user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko  
via: 1.1 vegur  

★Mac Safari
cache-control: no-cache  
connect-time: 1  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
pragma: no-cache  
sec-websocket-extensions: x-webkit-deflate-frame  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 1  
upgrade: websocket  
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/7.0.4 Safari/537.76.4  
via: 1.1 vegur  

★Android
cache-control: no-cache  
connect-time: 0  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
pragma: no-cache  
sec-websocket-extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 0  
upgrade: websocket  
user-agent: Mozilla/5.0 (Linux; Android 4.1.2; P-02E Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.141 Mobile Safari/537.36  
via: 1.1 vegur  

★iPad
cache-control: no-cache  
connect-time: 0  
connection: Upgrade  
Content-Length: 0  
Host: room-sandbox.herokuapp.com  
origin: http://shunjikonishi.github.io  
pragma: no-cache  
sec-websocket-extensions: x-webkit-deflate-frame  
sec-websocket-key: (snip)
sec-websocket-version: 13  
total-route-time: 0  
upgrade: websocket  
user-agent: Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53  
via: 1.1 vegur  

□□□□

ほとんど余計なヘッダはついてないですね。

Firefox以外はAccept, Appcept-Encoding, Accept-Languageはついていません。

なるほど。確かにHTMLページを返すことを目的としたプロトコルではないので付ける必要ないですね。

納得いきました。

コメント(0)