Internet Engineering Task Force (IETF) I. Fette
Request for Comments: 6455 Google, Inc.
Category: Standards Track A. Melnikov
ISSN: 2070-1721 Isode Ltd.
December 2011
The WebSocket Protocol
Abstract
The WebSocket Protocol enables two-way communication between a client
running untrusted code in a controlled environment to a remote host
that has opted-in to communications from that code. The security
model used for this is the origin-based security model commonly used
by web browsers. The protocol consists of an opening handshake
followed by basic message framing, layered over TCP. The goal of
this technology is to provide a mechanism for browser-based
applications that need two-way communication with servers that does
not rely on opening multiple HTTP connections (e.g., using
XMLHttpRequest or <iframe>s and long polling).
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc6455.
Copyright Notice
Copyright (c) 2011 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
Fette & Melnikov Standards Track [Page 1]
RFC 6455 The WebSocket Protocol December 2011
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2. Protocol Overview . . . . . . . . . . . . . . . . . . . . 5
1.3. Opening Handshake . . . . . . . . . . . . . . . . . . . . 6
1.4. Closing Handshake . . . . . . . . . . . . . . . . . . . . 9
1.5. Design Philosophy . . . . . . . . . . . . . . . . . . . . 9
1.6. Security Model . . . . . . . . . . . . . . . . . . . . . . 10
1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 11
1.8. Establishing a Connection . . . . . . . . . . . . . . . . 11
1.9. Subprotocols Using the WebSocket Protocol . . . . . . . . 12
2. Conformance Requirements . . . . . . . . . . . . . . . . . . . 12
2.1. Terminology and Other Conventions . . . . . . . . . . . . 13
3. WebSocket URIs . . . . . . . . . . . . . . . . . . . . . . . . 14
4. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 14
4.1. Client Requirements . . . . . . . . . . . . . . . . . . . 14
4.2. Server-Side Requirements . . . . . . . . . . . . . . . . . 20
4.2.1. Reading the Client's Opening Handshake . . . . . . . . 21
4.2.2. Sending the Server's Opening Handshake . . . . . . . . 22
4.3. Collected ABNF for New Header Fields Used in Handshake . . 25
4.4. Supporting Multiple Versions of WebSocket Protocol . . . . 26
5. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.2. Base Framing Protocol . . . . . . . . . . . . . . . . . . 28
5.3. Client-to-Server Masking . . . . . . . . . . . . . . . . . 32
5.4. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 33
5.5. Control Frames . . . . . . . . . . . . . . . . . . . . . . 36
5.5.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 36
5.5.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.5.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.6. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 38
5.7. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.8. Extensibility . . . . . . . . . . . . . . . . . . . . . . 39
6. Sending and Receiving Data . . . . . . . . . . . . . . . . . . 39
6.1. Sending Data . . . . . . . . . . . . . . . . . . . . . . . 39
6.2. Receiving Data . . . . . . . . . . . . . . . . . . . . . . 40
7. Closing the Connection . . . . . . . . . . . . . . . . . . . . 41
7.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 41
7.1.1. Close the WebSocket Connection . . . . . . . . . . . . 41
7.1.2. Start the WebSocket Closing Handshake . . . . . . . . 42
7.1.3. The WebSocket Closing Handshake is Started . . . . . . 42
7.1.4. The WebSocket Connection is Closed . . . . . . . . . . 42
7.1.5. The WebSocket Connection Close Code . . . . . . . . . 42
Fette & Melnikov Standards Track [Page 2]
RFC 6455 The WebSocket Protocol December 2011
7.1.6. The WebSocket Connection Close Reason . . . . . . . . 43
7.1.7. Fail the WebSocket Connection . . . . . . . . . . . . 43
7.2. Abnormal Closures . . . . . . . . . . . . . . . . . . . . 44
7.2.1. Client-Initiated Closure . . . . . . . . . . . . . . . 44
7.2.2. Server-Initiated Closure . . . . . . . . . . . . . . . 44
7.2.3. Recovering from Abnormal Closure . . . . . . . . . . . 44
7.3. Normal Closure of Connections . . . . . . . . . . . . . . 45
7.4. Status Codes . . . . . . . . . . . . . . . . . . . . . . . 45
7.4.1. Defined Status Codes . . . . . . . . . . . . . . . . . 45
7.4.2. Reserved Status Code Ranges . . . . . . . . . . . . . 47
8. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 48
8.1. Handling Errors in UTF-8-Encoded Data . . . . . . . . . . 48
9. Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9.1. Negotiating Extensions . . . . . . . . . . . . . . . . . . 48
9.2. Known Extensions . . . . . . . . . . . . . . . . . . . . . 50
10. Security Considerations . . . . . . . . . . . . . . . . . . . 50
10.1. Non-Browser Clients . . . . . . . . . . . . . . . . . . . 50
10.2. Origin Considerations . . . . . . . . . . . . . . . . . . 50
10.3. Attacks On Infrastructure (Masking) . . . . . . . . . . . 51
10.4. Implementation-Specific Limits . . . . . . . . . . . . . . 52
10.5. WebSocket Client Authentication . . . . . . . . . . . . . 53
10.6. Connection Confidentiality and Integrity . . . . . . . . . 53
10.7. Handling of Invalid Data . . . . . . . . . . . . . . . . . 53
10.8. Use of SHA-1 by the WebSocket Handshake . . . . . . . . . 54
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 54
11.1. Registration of New URI Schemes . . . . . . . . . . . . . 54
11.1.1. Registration of "ws" Scheme . . . . . . . . . . . . . 54
11.1.2. Registration of "wss" Scheme . . . . . . . . . . . . . 55
11.2. Registration of the "WebSocket" HTTP Upgrade Keyword . . . 56
11.3. Registration of New HTTP Header Fields . . . . . . . . . . 57
11.3.1. Sec-WebSocket-Key . . . .
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
XR872开发SDK 1.2.0版本 (2000个子文件)
cc936.c 697KB
cc949.c 546KB
y.tab.c 477KB
cc950.c 434KB
llhttp.c 419KB
nghttp2_session_test.c 391KB
ssl_tls.c 312KB
cc932.c 240KB
ssl_tls.c 235KB
nghttp2_session.c 232KB
ff.c 201KB
HTTPClient.c 178KB
nopoll_conn.c 178KB
tasks.c 166KB
ssl_srv.c 149KB
tasks.c 140KB
sockets.c 135KB
ssl_srv.c 125KB
ssl_cli.c 121KB
ssl_cli.c 108KB
ssl_server2.c 104KB
mib2.c 103KB
nghttp2_hd_huffman_data.c 103KB
ssl_ciphersuites.c 101KB
ecp.c 93KB
queue.c 91KB
sockets.c 91KB
httpd.c 89KB
httpd.c 85KB
tcp.c 84KB
nd6.c 83KB
rsa.c 83KB
tcp_in.c 81KB
string.c 81KB
ssl_ciphersuites.c 79KB
x509_crt.c 79KB
at_command.c 79KB
queue.c 78KB
server.c 76KB
snmp_msg.c 75KB
mdns.c 75KB
tcp_out.c 75KB
ssl_server2.c 74KB
dhcp.c 74KB
sockets.c 74KB
vm.c 74KB
functions.c 73KB
codegen.c 72KB
lcp.c 72KB
lcp.c 72KB
libwebsockets.c 71KB
aes.c 71KB
dhcp.c 70KB
bme280.c 70KB
ssl_client2.c 69KB
x509_crt.c 68KB
tcp_in.c 68KB
nd6.c 67KB
api_msg.c 67KB
bignum.c 66KB
tcp.c 66KB
snmp_msg.c 66KB
dhcp.c 64KB
mdns.c 63KB
auth.c 63KB
auth.c 63KB
ecp.c 63KB
ipcp.c 62KB
ipcp.c 62KB
nghttp2_hd.c 61KB
eap.c 61KB
eap.c 61KB
class.c 60KB
api_msg.c 60KB
sshd.c 59KB
tcp_in.c 59KB
ppp.c 57KB
ecp_curves.c 56KB
lcp.c 56KB
tcp_out.c 56KB
ssl_client2.c 55KB
nopoll.c 55KB
bignum.c 55KB
cipher_wrap.c 54KB
shttpd.c 53KB
ip6.c 53KB
test_tcp.c 53KB
tcp.c 52KB
dns.c 52KB
xradio_internal_codec.c 52KB
ecp_curves.c 51KB
netif.c 51KB
cJSON.c 51KB
etharp.c 51KB
dns.c 50KB
sdio.c 50KB
rsa.c 49KB
tcp_out.c 49KB
api_msg.c 49KB
pbuf.c 49KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
zwallow
- 粉丝: 2
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0