Sec-WebSocket-Protocol:

部分プロトコル (WebSocket)

[27] 部分プロトコル (subprotocol) は、 WebSocket 上で利用するプロトコルを表します。

仕様書

意味

[41] WebSocket部分プロトコルは、 WebSocket で送受信するアプリケーションプロトコルを識別するものです。

[42] 1つの WebSocket エンドポイントで複数のプロトコルを扱いたい時に、 相互の区別のために有用かもしれません。 しかしほとんどの用途では特定エンドポイントでは特定のプロトコルしか使わないでしょうから、 この機能が必要となる場面は滅多にありません。

構文

[23] 部分プロトコル名は、字句です >>22, >>1

[24] RFC は、,SP 以外のASCII印字可能文字であることを要求しつつ、ABNF では字句と定義しています。 ABNF に従うことや従わないものを拒絶することも (曖昧に) 求めています。結果としてどのような動作が求められているのかは不明確です。

[26] HTML Standard は、スクリプトが指定した値が 「Sec-WebSocket-Protocol: の要件を満たさないなら」 >>25 例外を投げることを求めています。

[40] Chrome字句でない文字空文字列を与えると、 例外を投げるようです。

文脈

[3] 要求では複数使えます。応答で複数使ってはなりません>>2

WebSocket インターフェイス protocol 属性

[34] WebSocket インターフェイスprotocol IDL属性は、 利用している部分プロトコルについて返すものです。

[35] この属性は、内部的に保持している値を返さなければなりません >>33。 値は、WebSocket接続の確立の過程で設定されます。

部分プロトコルの名前

[20] 部分プロトコルは、サーバークライアントとの合意があれば好きな名前を使って構いません。

[21] しかし広い範囲で使われるものは共通の名前があると便利ということで、 部分プロトコル名を規定する仕様書も存在しています。

[5] 部分プロトコルの名前には、IANA登録簿があります >>4, >>6

[7] 実際に色々な部分プロトコル名が登録されているようです。

[36] 大文字小文字は、区別されます。

[37] しかし大文字小文字の差しかない名前を IANA に登録することはできません >>32

[8] RFC 7118 - The WebSocket Protocol as a Transport for the Session Initiation Protocol (SIP) ( 版) <https://tools.ietf.org/html/rfc7118>

[9]rfbRFC 6143 を出典に登録されていますが、 RFC 6143WebSocket に言及しておらず、どのように使うのか不明です。

[14] draft-garnero-rfb-websocket-00 - The WebSocket Protocol as a Transport for the Remote Framebuffer Protocol (RFB) ( 版) <https://tools.ietf.org/html/draft-garnero-rfb-websocket-00>

[13] draft-realvnc-websocket-02 - Use of the WebSocket Protocol as a Transport for the Remote Framebuffer Protocol ( 版) <https://tools.ietf.org/html/draft-realvnc-websocket-02>

[10] RFC 7395 - An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket ( 版) <http://tools.ietf.org/html/rfc7395>

[11] draft-pd-dispatch-msrp-websocket-08 - The WebSocket Protocol as a Transport for the Message Session Relay Protocol (MSRP) ( 版) <https://tools.ietf.org/html/draft-pd-dispatch-msrp-websocket-08>

[12] draft-ietf-bfcpbis-bfcp-websocket-04 - The WebSocket Protocol as a Transport for the Binary Floor Control Protocol (BFCP) ( 版) <https://tools.ietf.org/html/draft-ietf-bfcpbis-bfcp-websocket-04>

[15] draft-hapner-hybi-messagebroker-subprotocol-03 - The MessageBroker WebSocket Subprotocol ( 版) <https://tools.ietf.org/html/draft-hapner-hybi-messagebroker-subprotocol-03>

[16] draft-iijima-netconf-websocket-ps-04 - NETCONF over WebSocket ( 版) <https://tools.ietf.org/html/draft-iijima-netconf-websocket-ps-04>

[17] draft-chenxin-behave-turn-websocket-01 - WebSocket Protocol as a Transport for Traversal Using Relays around NAT (TURN) ( 版) <https://tools.ietf.org/html/draft-chenxin-behave-turn-websocket-01>

[18] draft-savolainen-core-coap-websockets-04 - CoAP over WebSockets ( 版) <https://tools.ietf.org/html/draft-savolainen-core-coap-websockets-04>

[19] Writing WebSocket servers - WebSockets | MDN ( 版) <https://developer.mozilla.org/en-US/docs/WebSockets/Writing_WebSocket_servers>

To avoid name conflict, it's recommended to make your subprotocol name part of a domain string. If you are building a custom chat app that uses a proprietary format exclusive to Example Inc., then you might use this: Sec-WebSocket-Protocol: chat.example.com. For different versions, a widely-used method is to add a / followed by the version number, like chat.example.com/2.0. Note that this isn't required, it's just an optional convention, and you can use any string you wish.

[30] Define the WebSocket subprotocol check as part of response validation · whatwg/fetch@08f8560 ( 版) <https://github.com/whatwg/fetch/commit/08f8560f6cecaedc1c3372f9fff1ee39c3bfc86f>

[31] Define permessage-deflate extension and cache-mode for WebSocket · whatwg/fetch@267a8ef ( 版) <https://github.com/whatwg/fetch/commit/267a8effeacfe5d641010d1d4f4609f9602cdab6>

[38] RFC 7977 - The WebSocket Protocol as a Transport for the Message Session Relay Protocol (MSRP) () <https://tools.ietf.org/html/rfc7977>

[39] msg.nicovideo.jp#json