codecamp

3.WebSocket URI

WebSocket URI

本规范定义了两个URI方案,使用定义在RFC5234[RFC5234]中的ABNF句法、和术语和由URI规范RFC 3986 [RFC3986]定义的ABNF制品。

      ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
      wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]

      host = <host, defined in [RFC3986], Section 3.2.2>
      port = <port, defined in [RFC3986], Section 3.2.3>
      path = <path-abempty, defined in [RFC3986], Section 3.3>
      query = <query, defined in [RFC3986], Section 3.4>

端口组件是可选的;用于“WS”的默认端点是80,而用于“WSS”默认端口是443。

如果方案组件不区分大写匹配“wss”,URI被称为“安全的”(它是说,“设置了安全标记”)。

“resource-name”(在4.1节也称为/resource name/)可以通过连接以下来构造:

o "/" 如果路径组件是空

o 路径组件

o "?" 如果查询组件是非空

o 查询组件

片段(译者注:# Fragment)标识符在WebSocket URI中是无意义的且必须不用在这些URI上。任何URI方案,字符“#”,当不表示片段开始时,必须被转义为%23。

2 一致性要求
4 打开阶段握手
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }