draft-ietf-hybi-thewebsocketprotocol-06.txt | draft-ietf-hybi-thewebsocketprotocol-07.txt | |||
---|---|---|---|---|
HyBi Working Group I. Fette | HyBi Working Group I. Fette | |||
Internet-Draft Google, Inc. | Internet-Draft Google, Inc. | |||
Intended status: Standards Track February 25, 2011 | Intended status: Standards Track April 22, 2011 | |||
Expires: August 29, 2011 | Expires: October 24, 2011 | |||
The WebSocket protocol | The WebSocket protocol | |||
draft-ietf-hybi-thewebsocketprotocol-06 | draft-ietf-hybi-thewebsocketprotocol-07 | |||
Abstract | Abstract | |||
The WebSocket protocol enables two-way communication between a user | The WebSocket protocol enables two-way communication between a user | |||
agent running untrusted code running in a controlled environment to a | agent running untrusted code running in a controlled environment to a | |||
remote host that has opted-in to communications from that code. The | remote host that has opted-in to communications from that code. The | |||
security model used for this is the Origin-based security model | security model used for this is the Origin-based security model | |||
commonly used by Web browsers. The protocol consists of an initial | commonly used by Web browsers. The protocol consists of an initial | |||
handshake followed by basic message framing, layered over TCP. The | handshake followed by basic message framing, layered over TCP. The | |||
goal of this technology is to provide a mechanism for browser-based | goal of this technology is to provide a mechanism for browser-based | |||
skipping to change at page 1, line 41 | skipping to change at page 1, line 41 | |||
Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
Drafts is at http://datatracker.ietf.org/drafts/current/. | Drafts is at http://datatracker.ietf.org/drafts/current/. | |||
Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
This Internet-Draft will expire on August 29, 2011. | This Internet-Draft will expire on October 24, 2011. | |||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2011 IETF Trust and the persons identified as the | Copyright (c) 2011 IETF Trust and the persons identified as the | |||
document authors. All rights reserved. | document authors. All rights reserved. | |||
This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
(http://trustee.ietf.org/license-info) in effect on the date of | (http://trustee.ietf.org/license-info) in effect on the date of | |||
publication of this document. Please review these documents | publication of this document. Please review these documents | |||
skipping to change at page 2, line 20 | skipping to change at page 2, line 20 | |||
described in the Simplified BSD License. | described in the Simplified BSD License. | |||
Table of Contents | Table of Contents | |||
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 4 | 1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 4 | 1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 4 | |||
1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 6 | 1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 6 | |||
1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 8 | 1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 8 | |||
1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 9 | 1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 9 | |||
1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 9 | 1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 10 | |||
1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 10 | 1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 10 | |||
1.8. Establishing a connection . . . . . . . . . . . . . . . . 10 | 1.8. Establishing a connection . . . . . . . . . . . . . . . . 11 | |||
1.9. Subprotocols using the WebSocket protocol . . . . . . . . 11 | 1.9. Subprotocols using the WebSocket protocol . . . . . . . . 11 | |||
2. Conformance requirements . . . . . . . . . . . . . . . . . . . 12 | 2. Conformance requirements . . . . . . . . . . . . . . . . . . . 13 | |||
2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 12 | 2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 13 | |||
3. WebSocket URIs . . . . . . . . . . . . . . . . . . . . . . . . 14 | 3. WebSocket URIs . . . . . . . . . . . . . . . . . . . . . . . . 15 | |||
3.1. Parsing WebSocket URIs . . . . . . . . . . . . . . . . . . 14 | 3.1. Parsing WebSocket URIs . . . . . . . . . . . . . . . . . . 15 | |||
3.2. Constructing WebSocket URIs . . . . . . . . . . . . . . . 15 | 3.2. Constructing WebSocket URIs . . . . . . . . . . . . . . . 16 | |||
3.3. Valid WebSocket URIs . . . . . . . . . . . . . . . . . . . 15 | 3.3. Valid WebSocket URIs . . . . . . . . . . . . . . . . . . . 16 | |||
4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 16 | 4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 17 | |||
4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 16 | 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 17 | |||
4.2. Client-to-Server Masking . . . . . . . . . . . . . . . . . 16 | 4.2. Base Framing Protocol . . . . . . . . . . . . . . . . . . 17 | |||
4.3. Base Framing Protocol . . . . . . . . . . . . . . . . . . 17 | 4.3. Client-to-Server Masking . . . . . . . . . . . . . . . . . 20 | |||
4.4. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 19 | 4.4. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 21 | |||
4.5. Control Frames . . . . . . . . . . . . . . . . . . . . . . 21 | 4.5. Control Frames . . . . . . . . . . . . . . . . . . . . . . 23 | |||
4.5.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 21 | 4.5.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 23 | |||
4.5.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 21 | 4.5.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 24 | |||
4.5.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 22 | 4.5.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 24 | |||
4.6. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 22 | 4.6. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 24 | |||
4.7. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 22 | 4.7. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 25 | |||
4.8. Extensibility . . . . . . . . . . . . . . . . . . . . . . 23 | 4.8. Extensibility . . . . . . . . . . . . . . . . . . . . . . 25 | |||
5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 24 | 5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 27 | |||
5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 24 | 5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 27 | |||
5.2. Server-side requirements . . . . . . . . . . . . . . . . . 28 | 5.2. Server-side requirements . . . . . . . . . . . . . . . . . 31 | |||
5.2.1. Reading the client's opening handshake . . . . . . . . 29 | 5.2.1. Reading the client's opening handshake . . . . . . . . 32 | |||
5.2.2. Sending the server's opening handshake . . . . . . . . 29 | 5.2.2. Sending the server's opening handshake . . . . . . . . 32 | |||
6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 32 | 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 36 | |||
6.1. Handling errors in UTF-8 from the server . . . . . . . . . 32 | 6.1. Handling errors in UTF-8 from the server . . . . . . . . . 36 | |||
6.2. Handling errors in UTF-8 from the client . . . . . . . . . 32 | 6.2. Handling errors in UTF-8 from the client . . . . . . . . . 36 | |||
7. Closing the connection . . . . . . . . . . . . . . . . . . . . 33 | 7. Closing the connection . . . . . . . . . . . . . . . . . . . . 37 | |||
7.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 33 | 7.1. Definitions . . . . . . . . . . . . . . . . . . . . . . . 37 | |||
7.1.1. Close the WebSocket Connection . . . . . . . . . . . . 33 | 7.1.1. Close the WebSocket Connection . . . . . . . . . . . . 37 | |||
7.1.2. Start the WebSocket Closing Handshake . . . . . . . . 33 | 7.1.2. Start the WebSocket Closing Handshake . . . . . . . . 37 | |||
7.1.3. The WebSocket Connection Is Closed . . . . . . . . . . 33 | 7.1.3. The WebSocket Connection Is Closed . . . . . . . . . . 37 | |||
7.1.4. Fail the WebSocket Connection . . . . . . . . . . . . 33 | 7.1.4. Fail the WebSocket Connection . . . . . . . . . . . . 37 | |||
7.2. Abnormal closures . . . . . . . . . . . . . . . . . . . . 34 | 7.2. Abnormal closures . . . . . . . . . . . . . . . . . . . . 37 | |||
7.2.1. Client-initiated closure . . . . . . . . . . . . . . . 34 | 7.2.1. Client-initiated closure . . . . . . . . . . . . . . . 38 | |||
7.2.2. Server-initiated closure . . . . . . . . . . . . . . . 34 | 7.2.2. Server-initiated closure . . . . . . . . . . . . . . . 38 | |||
7.3. Normal closure of connections . . . . . . . . . . . . . . 34 | 7.3. Normal closure of connections . . . . . . . . . . . . . . 38 | |||
7.4. Status codes . . . . . . . . . . . . . . . . . . . . . . . 34 | 7.4. Status codes . . . . . . . . . . . . . . . . . . . . . . . 38 | |||
7.4.1. Defined Status Codes . . . . . . . . . . . . . . . . . 34 | 7.4.1. Defined Status Codes . . . . . . . . . . . . . . . . . 38 | |||
7.4.2. Reserved status code ranges . . . . . . . . . . . . . 35 | 7.4.2. Reserved status code ranges . . . . . . . . . . . . . 39 | |||
8. Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . 37 | 8. Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . 41 | |||
8.1. Negotiating extensions . . . . . . . . . . . . . . . . . . 37 | 8.1. Negotiating extensions . . . . . . . . . . . . . . . . . . 41 | |||
8.2. Known extensions . . . . . . . . . . . . . . . . . . . . . 38 | 8.2. Known extensions . . . . . . . . . . . . . . . . . . . . . 42 | |||
8.2.1. Compression . . . . . . . . . . . . . . . . . . . . . 38 | 8.2.1. Compression . . . . . . . . . . . . . . . . . . . . . 42 | |||
9. Security considerations . . . . . . . . . . . . . . . . . . . 40 | 9. Security considerations . . . . . . . . . . . . . . . . . . . 44 | |||
10. IANA considerations . . . . . . . . . . . . . . . . . . . . . 42 | 10. IANA considerations . . . . . . . . . . . . . . . . . . . . . 46 | |||
10.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 42 | 10.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 46 | |||
10.2. Registration of wss: scheme . . . . . . . . . . . . . . . 43 | 10.2. Registration of wss: scheme . . . . . . . . . . . . . . . 47 | |||
10.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 44 | 10.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 48 | |||
10.4. Sec-WebSocket-Key . . . . . . . . . . . . . . . . . . . . 44 | 10.4. Sec-WebSocket-Key . . . . . . . . . . . . . . . . . . . . 48 | |||
10.5. Sec-WebSocket-Extensions . . . . . . . . . . . . . . . . . 45 | 10.5. Sec-WebSocket-Extensions . . . . . . . . . . . . . . . . . 49 | |||
10.6. Sec-WebSocket-Accept . . . . . . . . . . . . . . . . . . . 46 | 10.6. Sec-WebSocket-Accept . . . . . . . . . . . . . . . . . . . 50 | |||
10.7. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 46 | 10.7. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 50 | |||
10.8. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 47 | 10.8. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 51 | |||
10.9. Sec-WebSocket-Version . . . . . . . . . . . . . . . . . . 47 | 10.9. Sec-WebSocket-Version . . . . . . . . . . . . . . . . . . 51 | |||
11. Using the WebSocket protocol from other specifications . . . . 49 | 11. Using the WebSocket protocol from other specifications . . . . 53 | |||
12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 50 | 12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 54 | |||
13. Appendix: List of Changes . . . . . . . . . . . . . . . . . . 51 | 13. References . . . . . . . . . . . . . . . . . . . . . . . . . . 55 | |||
13.1. Changes from -05 to -06 . . . . . . . . . . . . . . . . . 51 | 13.1. Normative References . . . . . . . . . . . . . . . . . . . 55 | |||
14. Normative References . . . . . . . . . . . . . . . . . . . . . 53 | 13.2. Informative References . . . . . . . . . . . . . . . . . . 56 | |||
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 55 | Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 57 | |||
1. Introduction | 1. Introduction | |||
1.1. Background | 1.1. Background | |||
_This section is non-normative._ | _This section is non-normative._ | |||
Historically, creating an instant messenger chat client as a Web | Historically, creating an instant messenger chat client as a Web | |||
application has required an abuse of HTTP to poll the server for | application has required an abuse of HTTP to poll the server for | |||
updates while sending upstream notifications as distinct HTTP calls. | updates while sending upstream notifications as distinct HTTP | |||
calls.[RFC6202] | ||||
This results in a variety of problems: | This results in a variety of problems: | |||
o The server is forced to use a number of different underlying TCP | o The server is forced to use a number of different underlying TCP | |||
connections for each client: one for sending information to the | connections for each client: one for sending information to the | |||
client, and a new one for each incoming message. | client, and a new one for each incoming message. | |||
o The wire protocol has a high overhead, with each client-to-server | o The wire protocol has a high overhead, with each client-to-server | |||
message having an HTTP header. | message having an HTTP header. | |||
skipping to change at page 5, line 4 | skipping to change at page 5, line 12 | |||
The handshake from the client looks as follows: | The handshake from the client looks as follows: | |||
GET /chat HTTP/1.1 | GET /chat HTTP/1.1 | |||
Host: server.example.com | Host: server.example.com | |||
Upgrade: websocket | Upgrade: websocket | |||
Connection: Upgrade | Connection: Upgrade | |||
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | |||
Sec-WebSocket-Origin: http://example.com | Sec-WebSocket-Origin: http://example.com | |||
Sec-WebSocket-Protocol: chat, superchat | Sec-WebSocket-Protocol: chat, superchat | |||
Sec-WebSocket-Version: 6 | Sec-WebSocket-Version: 7 | |||
The handshake from the server looks as follows: | The handshake from the server looks as follows: | |||
HTTP/1.1 101 Switching Protocols | HTTP/1.1 101 Switching Protocols | |||
Upgrade: websocket | Upgrade: websocket | |||
Connection: Upgrade | Connection: Upgrade | |||
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= | Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= | |||
Sec-WebSocket-Protocol: chat | Sec-WebSocket-Protocol: chat | |||
The leading line from the client follows the Request-Line format. | The leading line from the client follows the Request-Line format. | |||
The leading line from the server follows the Status-Line format. The | The leading line from the server follows the Status-Line format. The | |||
Request-Line and Status-Line productions are defined in [RFC2616]. | Request-Line and Status-Line productions are defined in [RFC2616]. | |||
After the leading line in both cases come an unordered set of | After the leading line in both cases come an unordered set of header | |||
headers. The meaning of these headers is specified in Section 5 of | fields. The meaning of these header fields is specified in Section 5 | |||
this document. Additional headers may also be present, such as | of this document. Additional header fields may also be present, such | |||
cookies required to identify the user. The format and parsing of | as cookies [I-D.ietf-httpstate-cookie] required to identify the user. | |||
headers is as defined in [RFC2616]. | The format and parsing of headers is as defined in [RFC2616]. | |||
Once the client and server have both sent their handshakes, and if | Once the client and server have both sent their handshakes, and if | |||
the handshake was successful, then the data transfer part starts. | the handshake was successful, then the data transfer part starts. | |||
This is a two-way communication channel where each side can, | This is a two-way communication channel where each side can, | |||
independently from the other, send data at will. | independently from the other, send data at will. | |||
Clients and servers, after a successful handshake, transfer data back | Clients and servers, after a successful handshake, transfer data back | |||
and forth in conceptual units referred to in this specification as | and forth in conceptual units referred to in this specification as | |||
"messages". A message is a complete unit of data at an application | "messages". A message is a complete unit of data at an application | |||
level, with the expectation that many or most applications | level, with the expectation that many or most applications | |||
implementing this protocol (such as web user agents) provide APIs in | implementing this protocol (such as web user agents) provide APIs in | |||
terms of sending and receiving messages. The websocket message does | terms of sending and receiving messages. The websocket message does | |||
not necessarily correspond to a particular network layer framing, as | not necessarily correspond to a particular network layer framing, as | |||
a fragmented message may be coalesced, or vice versa, e.g. by an | a fragmented message may be coalesced, or vice versa, e.g. by an | |||
intermediary. | intermediary. | |||
Data is sent on the wire in the form of frames that have an | Data is sent on the wire in the form of frames that have an | |||
associated type. Broadly speaking, there are types for textual data, | associated type. A message is composed of one or more frames, all of | |||
which is interpreted as UTF-8 text, binary data (whose interpretation | which contain the same type of data. Broadly speaking, there are | |||
is left up to the application), and control frames, which are not | types for textual data, which is interpreted as UTF-8 [RFC3629] text, | |||
intended to carry data for the application, but instead for protocol- | binary data (whose interpretation is left up to the application), and | |||
level signaling, such as to signal that the connection should be | control frames, which are not intended to carry data for the | |||
closed. This version of the protocol defines six frame types and | application, but instead for protocol-level signaling, such as to | |||
leaves ten reserved for future use. | signal that the connection should be closed. This version of the | |||
protocol defines six frame types and leaves ten reserved for future | ||||
use. | ||||
The WebSocket protocol uses this framing so that specifications that | The WebSocket protocol uses this framing so that specifications that | |||
use the WebSocket protocol can expose such connections using an | use the WebSocket protocol can expose such connections using an | |||
event-based mechanism instead of requiring users of those | event-based mechanism instead of requiring users of those | |||
specifications to implement buffering and piecing together of | specifications to implement buffering and piecing together of | |||
messages manually. | messages manually. | |||
1.3. Opening handshake | 1.3. Opening handshake | |||
_This section is non-normative._ | _This section is non-normative._ | |||
skipping to change at page 6, line 24 | skipping to change at page 6, line 33 | |||
clients talking to that server. To this end, the WebSocket client's | clients talking to that server. To this end, the WebSocket client's | |||
handshake is an HTTP Upgrade request: | handshake is an HTTP Upgrade request: | |||
GET /chat HTTP/1.1 | GET /chat HTTP/1.1 | |||
Host: server.example.com | Host: server.example.com | |||
Upgrade: websocket | Upgrade: websocket | |||
Connection: Upgrade | Connection: Upgrade | |||
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | |||
Sec-WebSocket-Origin: http://example.com | Sec-WebSocket-Origin: http://example.com | |||
Sec-WebSocket-Protocol: chat, superchat | Sec-WebSocket-Protocol: chat, superchat | |||
Sec-WebSocket-Version: 6 | Sec-WebSocket-Version: 7 | |||
Headers in the handshake are sent by the client in a random order; | Headers in the handshake are sent by the client in a random order; | |||
the order is not meaningful. | the order is not meaningful. | |||
The "Request-URI" of the GET method [RFC2616] is used to identify the | ||||
endpoint of the WebSocket connection, both to allow multiple domains | ||||
to be served from one IP address and to allow multiple WebSocket | ||||
endpoints to be served by a single server. | ||||
The client includes the hostname in the Host header of its handshake | ||||
as per [RFC2616], so that both the client and the server can verify | ||||
that they agree on which host is in use. | ||||
Additional headers are used to select options in the WebSocket | Additional headers are used to select options in the WebSocket | |||
protocol. Options available in this version are the subprotocol | protocol. Options available in this version are the subprotocol | |||
selector, |Sec-WebSocket-Protocol|, and |Cookie|, which can used for | selector, |Sec-WebSocket-Protocol|, and |Cookie|, which can used for | |||
sending cookies to the server (e.g. as an authentication mechanism). | sending cookies to the server (e.g. as an authentication mechanism). | |||
The |Sec-WebSocket-Protocol| request-header field can be used to | The |Sec-WebSocket-Protocol| request-header field can be used to | |||
indicate what subprotocols (application-level protocols layered over | indicate what subprotocols (application-level protocols layered over | |||
the WebSocket protocol) are acceptable to the client. The server | the WebSocket protocol) are acceptable to the client. The server | |||
selects one of the acceptable protocols and echoes that value in its | selects one of the acceptable protocols and echoes that value in its | |||
handshake to indicate that it has selected that protocol. | handshake to indicate that it has selected that protocol. | |||
Sec-WebSocket-Protocol: chat | Sec-WebSocket-Protocol: chat | |||
The "Request-URI" of the GET method [RFC2616] is used to identify the | ||||
endpoint of the WebSocket connection, both to allow multiple domains | ||||
to be served from one IP address and to allow multiple WebSocket | ||||
endpoints to be served by a single server. | ||||
The client includes the hostname in the Host header of its handshake | ||||
as per [RFC2616], so that both the client and the server can verify | ||||
that they agree on which host is in use. | ||||
The |Sec-WebSocket-Origin| header is used to protect against | The |Sec-WebSocket-Origin| header is used to protect against | |||
unauthorized cross-origin use of a WebSocket server by scripts using | unauthorized cross-origin use of a WebSocket server by scripts using | |||
the |WebSocket| API in a Web browser. The server is informed of the | the |WebSocket| API in a Web browser. The server is informed of the | |||
script origin generating the WebSocket connection request. If the | script origin generating the WebSocket connection request. If the | |||
server does not wish to accept connections from this origin, it can | server does not wish to accept connections from this origin, it can | |||
choose to abort the connection. This header is sent by browser | choose to abort the connection. This header is sent by browser | |||
clients, for non-browser clients this header may be sent if it makes | clients, for non-browser clients this header may be sent if it makes | |||
sense in the context of those clients. | sense in the context of those clients. | |||
Finally, the server has to prove to the client that it received the | Finally, the server has to prove to the client that it received the | |||
skipping to change at page 7, line 25 | skipping to change at page 7, line 35 | |||
crafted packets using |XMLHttpRequest| or a |form| submission. | crafted packets using |XMLHttpRequest| or a |form| submission. | |||
To prove that the handshake was received, the server has to take two | To prove that the handshake was received, the server has to take two | |||
pieces of information and combine them to form a response. The first | pieces of information and combine them to form a response. The first | |||
piece of information comes from the |Sec-WebSocket-Key| header in the | piece of information comes from the |Sec-WebSocket-Key| header in the | |||
client handshake: | client handshake: | |||
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== | |||
For this header, the server has to take the value (as present in the | For this header, the server has to take the value (as present in the | |||
header, e.g. the base64-encoded version), and concatenate this with | header, e.g. the base64-encoded [RFC4648] version minus leading and | |||
the GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" in string form, which | trailing whitespace), and concatenate this with the GUID "258EAFA5- | |||
is unlikely to be used by network endpoints that do not understand | E914-47DA-95CA-C5AB0DC85B11" in string form, which is unlikely to be | |||
the WebSocket protocol. A SHA-1 hash, base64-encoded, of this | used by network endpoints that do not understand the WebSocket | |||
concatenation is then returned in the server's handshake | protocol. A SHA-1 hash, base64-encoded, of this concatenation is | |||
[FIPS.180-2.2002]. | then returned in the server's handshake [FIPS.180-2.2002]. | |||
Concretely, if as in the example above, header |Sec-WebSocket-Key| | Concretely, if as in the example above, header |Sec-WebSocket-Key| | |||
had the value "dGhlIHNhbXBsZSBub25jZQ==", the server would | had the value "dGhlIHNhbXBsZSBub25jZQ==", the server would | |||
concatenate the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" to form | concatenate the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" to form | |||
the string "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA- | the string "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA- | |||
C5AB0DC85B11". The server would then take the SHA-1 hash of this, | C5AB0DC85B11". The server would then take the SHA-1 hash of this, | |||
giving the value 0xb3 0x7a 0x4f 0x2c 0xc0 0x62 0x4f 0x16 0x90 0xf6 | giving the value 0xb3 0x7a 0x4f 0x2c 0xc0 0x62 0x4f 0x16 0x90 0xf6 | |||
0x46 0x06 0xcf 0x38 0x59 0x45 0xb2 0xbe 0xc4 0xea. This value is | 0x46 0x06 0xcf 0x38 0x59 0x45 0xb2 0xbe 0xc4 0xea. This value is | |||
then base64-encoded, to give the value "s3pPLMBiTxaQ9kYGzzhZRbK+ | then base64-encoded, to give the value "s3pPLMBiTxaQ9kYGzzhZRbK+ | |||
xOo=". This value would then be echoed in the header |Sec-WebSocket- | xOo=". This value would then be echoed in the header |Sec-WebSocket- | |||
Accept|. | Accept|. | |||
The handshake from the server is much simpler than the client | The handshake from the server is much simpler than the client | |||
handshake. The first line is an HTTP Status-Line, with the status | handshake. The first line is an HTTP Status-Line, with the status | |||
code 101: | code 101: | |||
HTTP/1.1 101 Switching Protocols | HTTP/1.1 101 Switching Protocols | |||
Any status code other than 101 MUST be treated as a failure if | Any status code other than 101 indicates that the WebSocket handshake | |||
semantics of that status code are not defined in the context of a | has not completed, and that the semantics of HTTP still apply. The | |||
WebSocket connection, and the websocket connection aborted. The | ||||
headers follow the status code. | headers follow the status code. | |||
The |Connection| and |Upgrade| headers complete the HTTP Upgrade. | The |Connection| and |Upgrade| headers complete the HTTP Upgrade. | |||
The |Sec-WebSocket-Accept| header indicates whether the server is | The |Sec-WebSocket-Accept| header indicates whether the server is | |||
willing to accept the connection. If present, this header must | willing to accept the connection. If present, this header must | |||
include a hash of the client's nonce sent in |Sec-WebSocket-Key| | include a hash of the client's nonce sent in |Sec-WebSocket-Key| | |||
along with a predefined GUID. Any other value must not be | along with a predefined GUID. Any other value must not be | |||
interpreted as an acceptance of the connection by the server. | interpreted as an acceptance of the connection by the server. | |||
HTTP/1.1 101 Switching Protocols | HTTP/1.1 101 Switching Protocols | |||
skipping to change at page 8, line 29 | skipping to change at page 8, line 37 | |||
These fields are checked by the Web browser when it is acting as a | These fields are checked by the Web browser when it is acting as a | |||
|WebSocket| client for scripted pages. If the |Sec-WebSocket-Accept| | |WebSocket| client for scripted pages. If the |Sec-WebSocket-Accept| | |||
value does not match the expected value, or if the header is missing, | value does not match the expected value, or if the header is missing, | |||
or if the HTTP status code is not 101, the connection will not be | or if the HTTP status code is not 101, the connection will not be | |||
established and WebSockets frames will not be sent. | established and WebSockets frames will not be sent. | |||
Option fields can also be included. In this version of the protocol, | Option fields can also be included. In this version of the protocol, | |||
the main option field is |Sec-WebSocket-Protocol|, which indicates | the main option field is |Sec-WebSocket-Protocol|, which indicates | |||
the subprotocol that the server has selected. Web browsers verify | the subprotocol that the server has selected. Web browsers verify | |||
that the server included one of the values as was specified in the | that the server included one of the values as was specified in the | |||
|WebSocket| constructor. A server that speaks multiple subprotocols | WebSocket client' handshake. A server that speaks multiple | |||
has to make sure it selects one based on the client's handshake and | subprotocols has to make sure it selects one based on the client's | |||
specifies it in its handshake. | handshake and specifies it in its handshake. | |||
Sec-WebSocket-Protocol: chat | Sec-WebSocket-Protocol: chat | |||
The server can also set cookie-related option fields to _set_ | The server can also set cookie-related option fields to _set_ | |||
cookies, as in HTTP. | cookies, as in HTTP. | |||
1.4. Closing handshake | 1.4. Closing handshake | |||
_This section is non-normative._ | _This section is non-normative._ | |||
skipping to change at page 9, line 18 | skipping to change at page 9, line 26 | |||
discards any further data received. | discards any further data received. | |||
It is safe for both peers to initiate this handshake simultaneously. | It is safe for both peers to initiate this handshake simultaneously. | |||
The closing handshake is intended to replace the TCP closing | The closing handshake is intended to replace the TCP closing | |||
handshake (FIN/ACK), on the basis that the TCP closing handshake is | handshake (FIN/ACK), on the basis that the TCP closing handshake is | |||
not always reliable end-to-end, especially in the presence of man-in- | not always reliable end-to-end, especially in the presence of man-in- | |||
the-middle proxies and other intermediaries. | the-middle proxies and other intermediaries. | |||
By sending a close frame and waiting for a close frame in response, | By sending a close frame and waiting for a close frame in response, | |||
certain cases are avoided where data may be unnecessarily lost. For | ||||
instance, on some platforms, if a socket is closed with data in the | ||||
receive queue, a RST packet is sent, which will then cause recv() to | ||||
fail for the party that received the RST, even if there was data | ||||
waiting to be read. | ||||
1.5. Design philosophy | 1.5. Design philosophy | |||
_This section is non-normative._ | _This section is non-normative._ | |||
The WebSocket protocol is designed on the principle that there should | The WebSocket protocol is designed on the principle that there should | |||
be minimal framing (the only framing that exists is to make the | be minimal framing (the only framing that exists is to make the | |||
protocol frame-based instead of stream-based, and to support a | protocol frame-based instead of stream-based, and to support a | |||
distinction between Unicode text and binary frames). It is expected | distinction between Unicode text and binary frames). It is expected | |||
that metadata would be layered on top of WebSocket by the application | that metadata would be layered on top of WebSocket by the application | |||
skipping to change at page 9, line 41 | skipping to change at page 10, line 5 | |||
Conceptually, WebSocket is really just a layer on top of TCP that | Conceptually, WebSocket is really just a layer on top of TCP that | |||
adds a Web "origin"-based security model for browsers; adds an | adds a Web "origin"-based security model for browsers; adds an | |||
addressing and protocol naming mechanism to support multiple services | addressing and protocol naming mechanism to support multiple services | |||
on one port and multiple host names on one IP address; layers a | on one port and multiple host names on one IP address; layers a | |||
framing mechanism on top of TCP to get back to the IP packet | framing mechanism on top of TCP to get back to the IP packet | |||
mechanism that TCP is built on, but without length limits; and re- | mechanism that TCP is built on, but without length limits; and re- | |||
implements the closing handshake in-band. Other than that, it adds | implements the closing handshake in-band. Other than that, it adds | |||
nothing. Basically it is intended to be as close to just exposing | nothing. Basically it is intended to be as close to just exposing | |||
raw TCP to script as possible given the constraints of the Web. It's | raw TCP to script as possible given the constraints of the Web. It's | |||
also designed in such a way that its servers can share a port with | also designed in such a way that its servers can share a port with | |||
HTTP servers, by having its handshake be a valid HTTP Upgrade | HTTP servers, by having its handshake be a valid HTTP Upgrade request | |||
handshake also. | mechanism also. | |||
The protocol is intended to be extensible; future versions will | The protocol is intended to be extensible; future versions will | |||
likely introduce additional concepts such as multiplexing. | likely introduce additional concepts such as multiplexing. | |||
1.6. Security model | 1.6. Security model | |||
_This section is non-normative._ | _This section is non-normative._ | |||
The WebSocket protocol uses the origin model used by Web browsers to | The WebSocket protocol uses the origin model used by Web browsers to | |||
restrict which Web pages can contact a WebSocket server when the | restrict which Web pages can contact a WebSocket server when the | |||
WebSocket protocol is used from a Web page. Naturally, when the | WebSocket protocol is used from a Web page. Naturally, when the | |||
WebSocket protocol is used by a dedicated client directly (i.e. not | WebSocket protocol is used by a dedicated client directly (i.e. not | |||
from a Web page through a Web browser), the origin model is not | from a Web page through a Web browser), the origin model is not | |||
useful, as the client can provide any arbitrary origin string. | useful, as the client can provide any arbitrary origin string. | |||
This protocol is intended to fail to establish a connection with | This protocol is intended to fail to establish a connection with | |||
servers of pre-existing protocols like SMTP or HTTP, while allowing | servers of pre-existing protocols like SMTP [RFC5321] and HTTP, while | |||
HTTP servers to opt-in to supporting this protocol if desired. This | allowing HTTP servers to opt-in to supporting this protocol if | |||
is achieved by having a strict and elaborate handshake, and by | desired. This is achieved by having a strict and elaborate | |||
limiting the data that can be inserted into the connection before the | handshake, and by limiting the data that can be inserted into the | |||
handshake is finished (thus limiting how much the server can be | connection before the handshake is finished (thus limiting how much | |||
influenced). | the server can be influenced). | |||
It is similarly intended to fail to establish a connection when data | It is similarly intended to fail to establish a connection when data | |||
from other protocols, especially HTTP, is sent to a WebSocket server, | from other protocols, especially HTTP, is sent to a WebSocket server, | |||
for example as might happen if an HTML |form| were submitted to a | for example as might happen if an HTML |form| were submitted to a | |||
WebSocket server. This is primarily achieved by requiring that the | WebSocket server. This is primarily achieved by requiring that the | |||
server prove that it read the handshake, which it can only do if the | server prove that it read the handshake, which it can only do if the | |||
handshake contains the appropriate parts which themselves can only be | handshake contains the appropriate parts which themselves can only be | |||
sent by a WebSocket handshake. In particular, at the time of writing | sent by a WebSocket handshake. In particular, at the time of writing | |||
of this specification, fields starting with |Sec-| cannot be set by | of this specification, fields starting with |Sec-| cannot be set by | |||
an attacker from a Web browser using only HTML and JavaScript APIs | an attacker from a Web browser using only HTML and JavaScript APIs | |||
such as |XMLHttpRequest|. | such as |XMLHttpRequest|. | |||
1.7. Relationship to TCP and HTTP | 1.7. Relationship to TCP and HTTP | |||
_This section is non-normative._ | _This section is non-normative._ | |||
The WebSocket protocol is an independent TCP-based protocol. Its | The WebSocket protocol is an independent TCP-based protocol. Its | |||
only relationship to HTTP is that its handshake is interpreted by | only relationship to HTTP is that its handshake is interpreted by | |||
HTTP servers as an Upgrade request. | HTTP servers as an Upgrade request. | |||
Based on the expert recommendation of the IANA, the WebSocket | By default the WebSocket protocol uses port 80 for regular WebSocket | |||
protocol by default uses port 80 for regular WebSocket connections | connections and port 443 for WebSocket connections tunneled over TLS | |||
and port 443 for WebSocket connections tunneled over TLS. | [RFC2818]. | |||
1.8. Establishing a connection | 1.8. Establishing a connection | |||
_This section is non-normative._ | _This section is non-normative._ | |||
When a connection is to be made to a port that is shared by an HTTP | When a connection is to be made to a port that is shared by an HTTP | |||
server (a situation that is quite likely to occur with traffic to | server (a situation that is quite likely to occur with traffic to | |||
ports 80 and 443), the connection will appear to the HTTP server to | ports 80 and 443), the connection will appear to the HTTP server to | |||
be a regular GET request with an Upgrade offer. In relatively simple | be a regular GET request with an Upgrade offer. In relatively simple | |||
setups with just one IP address and a single server for all traffic | setups with just one IP address and a single server for all traffic | |||
skipping to change at page 12, line 13 | skipping to change at page 13, line 13 | |||
of extensibility. | of extensibility. | |||
2. Conformance requirements | 2. Conformance requirements | |||
All diagrams, examples, and notes in this specification are non- | All diagrams, examples, and notes in this specification are non- | |||
normative, as are all sections explicitly marked non-normative. | normative, as are all sections explicitly marked non-normative. | |||
Everything else in this specification is normative. | Everything else in this specification is normative. | |||
The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", | The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", | |||
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this | "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this | |||
document are to be interpreted as described in RFC2119. For | document are to be interpreted as described in RFC2119. [RFC2119] | |||
readability, these words do not appear in all uppercase letters in | ||||
this specification. [RFC2119] | ||||
Requirements phrased in the imperative as part of algorithms (such as | Requirements phrased in the imperative as part of algorithms (such as | |||
"strip any leading space characters" or "return false and abort these | "strip any leading space characters" or "return false and abort these | |||
steps") are to be interpreted with the meaning of the key word | steps") are to be interpreted with the meaning of the key word | |||
("must", "should", "may", etc) used in introducing the algorithm. | ("must", "should", "may", etc) used in introducing the algorithm. | |||
Conformance requirements phrased as algorithms or specific steps may | Conformance requirements phrased as algorithms or specific steps MAY | |||
be implemented in any manner, so long as the end result is | be implemented in any manner, so long as the end result is | |||
equivalent. (In particular, the algorithms defined in this | equivalent. (In particular, the algorithms defined in this | |||
specification are intended to be easy to follow, and not intended to | specification are intended to be easy to follow, and not intended to | |||
be performant.) | be performant.) | |||
Implementations may impose implementation-specific limits on | Implementations MAY impose implementation-specific limits on | |||
otherwise unconstrained inputs, e.g. to prevent denial of service | otherwise unconstrained inputs, e.g. to prevent denial of service | |||
attacks, to guard against running out of memory, or to work around | attacks, to guard against running out of memory, or to work around | |||
platform-specific limitations. | platform-specific limitations. | |||
The conformance classes defined by this specification are user agents | The conformance classes defined by this specification are user agents | |||
and servers. | and servers. | |||
2.1. Terminology | 2.1. Terminology | |||
*ASCII* shall mean the character-encoding scheme defined in | *ASCII* shall mean the character-encoding scheme defined in | |||
skipping to change at page 13, line 5 | skipping to change at page 13, line 52 | |||
range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL | range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL | |||
LETTER Z). | LETTER Z). | |||
Comparing two strings in an *ASCII case-insensitive* manner means | Comparing two strings in an *ASCII case-insensitive* manner means | |||
comparing them exactly, code point for code point, except that the | comparing them exactly, code point for code point, except that the | |||
characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER | characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER | |||
A to LATIN CAPITAL LETTER Z) and the corresponding characters in the | A to LATIN CAPITAL LETTER Z) and the corresponding characters in the | |||
range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL | range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL | |||
LETTER Z) are considered to also match. | LETTER Z) are considered to also match. | |||
The term "URI" is used in this section in a manner consistent with | The term "URI" is used in this document as defined in [RFC3986]. | |||
the terminology used in HTML, namely, to denote a string that might | ||||
or might not be a valid URI or IRI and to which certain error | ||||
handling behaviors will be applied when the string is parsed. | ||||
[RFC3986] | ||||
When an implementation is required to _send_ data as part of the | When an implementation is required to _send_ data as part of the | |||
WebSocket protocol, the implementation may delay the actual | WebSocket protocol, the implementation MAY delay the actual | |||
transmission arbitrarily, e.g. buffering data so as to send fewer IP | transmission arbitrarily, e.g. buffering data so as to send fewer IP | |||
packets. | packets. | |||
3. WebSocket URIs | 3. WebSocket URIs | |||
3.1. Parsing WebSocket URIs | 3.1. Parsing WebSocket URIs | |||
The steps to *parse a WebSocket URI's components* from a string /uri/ | The steps to *parse a WebSocket URI's components* from a string /uri/ | |||
are as follows. These steps return either a /host/, a /port/, a | are as follows. These steps return either a /host/, a /port/, a | |||
/resource name/, and a /secure/ flag, or they fail. | /resource name/, and a /secure/ flag, or they fail. | |||
1. If the /uri/ string is not an absolute URI, then fail this | 1. If the /uri/ string is not an absolute URI, then fail this | |||
algorithm. [RFC3986] [RFC3987] | algorithm. [RFC3986] | |||
2. Resolve the /uri/ string using the resolve a Web address | 2. Resolve the /uri/ string using the resolve a Web address | |||
algorithm defined by the Web addresses specification, with the | algorithm defined by the Web addresses specification, with the | |||
URI character encoding set to UTF-8. [RFC3629] [RFC3986] | URI character encoding set to UTF-8. [RFC3629] [RFC3986] | |||
[RFC3987] | [RFC3987] | |||
NOTE: It doesn't matter what it is resolved relative to, since | NOTE: It doesn't matter what it is resolved relative to, since | |||
we already know it is an absolute URI at this point. | we already know it is an absolute URI at this point. | |||
3. If /uri/ does not have a <scheme> component whose value, when | 3. If /uri/ does not have a <scheme> component whose value, when | |||
converted to ASCII lowercase, is either "ws" or "wss", then fail | converted to ASCII lowercase, is either "ws" or "wss", then fail | |||
this algorithm. | this algorithm. | |||
4. If /uri/ has a <fragment> component, then fail this algorithm. | 4. If /uri/ has a <fragment> component, then fail this algorithm. | |||
5. If the <scheme> component of /uri/ is "ws", set /secure/ to | 5. If the <scheme> component of /uri/ is "ws", set /secure/ to | |||
false; otherwise, if the <scheme> component is "wss", set | false; otherwise, if the <scheme> component is "wss", set | |||
/secure/ to true; otherwise, fail this algorithm. | /secure/ to true; if neither of the above apply, fail this | |||
algorithm. | ||||
6. Let /host/ be the value of the <host> component of /uri/, | 6. Let /host/ be the value of the <host> component of /uri/, | |||
converted to ASCII lowercase. | converted to ASCII lowercase. | |||
7. If /uri/ has a <port> component, then let /port/ be that | 7. If /uri/ has a <port> component, then let /port/ be that | |||
component's value; otherwise, there is no explicit /port/. | component's value; otherwise, there is no explicit /port/. | |||
8. If there is no explicit /port/, then: if /secure/ is false, let | 8. If there is no explicit /port/, then: if /secure/ is false, let | |||
/port/ be 80, otherwise let /port/ be 443. | /port/ be 80, otherwise let /port/ be 443. | |||
skipping to change at page 15, line 32 | skipping to change at page 16, line 32 | |||
5. Append /resource name/ to /uri/. | 5. Append /resource name/ to /uri/. | |||
6. Return /uri/. | 6. Return /uri/. | |||
3.3. Valid WebSocket URIs | 3.3. Valid WebSocket URIs | |||
For a WebSocket URI to be considered valid, the following conditions | For a WebSocket URI to be considered valid, the following conditions | |||
MUST hold. | MUST hold. | |||
o The /host/ must be ASCII-only (i.e. it must have been punycode- | o The /host/ MUST be ASCII-only (i.e. it MUST have been punycode- | |||
encoded already if necessary, and MUST NOT contain any characters | encoded [RFC3492] already if necessary, and MUST NOT contain any | |||
above U+007E). | characters above U+007E). | |||
o The /resource name/ string must be a non-empty string of | o The /resource name/ string MUST be a non-empty string of | |||
characters in the range U+0021 to U+007E that starts with a U+002F | characters in the range U+0021 to U+007E and MUST start with a | |||
SOLIDUS character (/). | U+002F SOLIDUS character (/). | |||
Any WebSocket URIs not meeting the above criteria are considered | Any WebSocket URIs not meeting the above criteria are considered | |||
invalid, and a client MUST NOT attempt to make a connection to an | invalid. A client MUST NOT attempt to make a connection to an | |||
invalid WebSocket URI. A client SHOULD attempt to parse a URI | invalid WebSocket URI. A client SHOULD attempt to parse a URI | |||
obtained from any external source (such as a web site or a user) | obtained from any external source (such as a web site or a user) | |||
using the steps specified in Section 3.1 to obtain a valid WebSocket | using the steps specified in Section 3.1 to obtain a valid WebSocket | |||
URI, but MUST NOT attempt to connect with such an unparsed URI, and | URI, but MUST NOT attempt to connect with such an unparsed URI, and | |||
instead only use the parsed version and only if that version is | instead only use the parsed version and only if that version is | |||
considered valid by the criteria above. | considered valid by the criteria above. | |||
4. Data Framing | 4. Data Framing | |||
4.1. Overview | 4.1. Overview | |||
In the WebSocket protocol, data is transmitted using a sequence of | In the WebSocket protocol, data is transmitted using a sequence of | |||
frames. Frames sent from the client to the server are masked to | frames. Frames sent from the client to the server are masked to | |||
avoid confusing network intermediaries, such as intercepting proxies. | avoid confusing network intermediaries, such as intercepting proxies. | |||
Frames sent from the server to the client are not masked. | Frames sent from the server to the client are not masked. | |||
The base framing protocol defines a frame type with an opcode, a | The base framing protocol defines a frame type with an opcode, a | |||
payload length, and designated locations for extension and | payload length, and designated locations for extension and | |||
application data, which together define the _payload_ data. Certain | application data, which together define the _payload_ data. Certain | |||
bits and opcodes are reserved for future expansion of the protocol. | bits and opcodes are reserved for future expansion of the protocol. | |||
As such, In the absence of extensions negotiated during the opening | As such, in the absence of extensions negotiated during the opening | |||
handshake (Section 5), all reserved bits MUST be 0 and reserved | handshake (Section 5), all reserved bits MUST be 0 and reserved | |||
opcode values MUST NOT be used. | opcode values MUST NOT be used. | |||
A data frame MAY be transmitted by either the client or the server at | A data frame MAY be transmitted by either the client or the server at | |||
any time after handshake completion and before that endpoint has sent | any time after handshake completion and before that endpoint has sent | |||
a close message (Section 4.5.1). | a close message (Section 4.5.1). | |||
4.2. Client-to-Server Masking | 4.2. Base Framing Protocol | |||
The client MUST mask all frames sent to the server. | ||||
The masking-key is contained completely within the frame. | ||||
The masking-key is a 32-bit value chosen at random by the client. | ||||
The masking-key MUST be derived from a strong source of entropy, and | ||||
the masking-key for a given frame MUST NOT make it simple for a | ||||
server to predict the masking-key for a subsequent frame. | ||||
Each masked frame consists of a 32-bit masking-key followed by | ||||
masked-data: | ||||
masked-frame = masking-key masked-data | ||||
masking-key = 4full-octet | ||||
masked-data = *full-octet | ||||
full-octet = %x00-FF | ||||
The masked-data is the clear-text frame "encrypted" using a simple | ||||
XOR cipher as follows. | ||||
Octet i of the masked-data is the XOR of octet i of the clear text | ||||
frame with octet i modulo 4 of the masking-key: | ||||
j = i MOD 4 | ||||
masked-octet-i = clear-text-octet-i XOR octet-j-of-masking-key | ||||
When preparing a masked-frame, the client MUST pick a fresh masking- | ||||
key uniformly at random from the set of allowed 32-bit values. The | ||||
unpredictability of the masking-nonce is essential to prevent the | ||||
author of malicious application data from selecting the bytes that | ||||
appear on the wire. | ||||
4.3. Base Framing Protocol | ||||
This wire format for the data transfer part is described by the ABNF | This wire format for the data transfer part is described by the ABNF | |||
given in detail in this section. A high level overview of the | [RFC5234] given in detail in this section. A high level overview of | |||
framing is given in the following figure. [RFC5234] | the framing is given in the following figure. | |||
0 1 2 3 | 0 1 2 3 | |||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | |||
+-+-+-+-+-------+-+-------------+-------------------------------+ | +-+-+-+-+-------+-+-------------+-------------------------------+ | |||
|F|R|R|R| opcode|R| Payload len | Extended payload length | | |F|R|R|R| opcode|M| Payload len | Extended payload length | | |||
|I|S|S|S| (4) |S| (7) | (16/63) | | |I|S|S|S| (4) |A| (7) | (16/63) | | |||
|N|V|V|V| |V| | (if payload len==126/127) | | |N|V|V|V| |S| | (if payload len==126/127) | | |||
| |1|2|3| |4| | | | | |1|2|3| |K| | | | |||
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | |||
| Extended payload length continued, if payload len == 127 | | | Extended payload length continued, if payload len == 127 | | |||
+ - - - - - - - - - - - - - - - +-------------------------------+ | + - - - - - - - - - - - - - - - +-------------------------------+ | |||
| | Extension data | | | |Masking-key, if MASK set to 1 | | |||
+-------------------------------+ - - - - - - - - - - - - - - - + | +-------------------------------+-------------------------------+ | |||
: : | | Masking-key (continued) | Payload Data | | |||
+---------------------------------------------------------------+ | +-------------------------------- - - - - - - - - - - - - - - - + | |||
: Application data : | : Payload Data continued ... : | |||
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | ||||
| Payload Data continued ... | | ||||
+---------------------------------------------------------------+ | +---------------------------------------------------------------+ | |||
FIN: 1 bit | FIN: 1 bit | |||
Indicates that this is the final fragment in a message. The first | Indicates that this is the final fragment in a message. The first | |||
fragment may also be the final fragment. | fragment MAY also be the final fragment. | |||
RSV1, RSV2, RSV3, RSV4: 1 bit each | RSV1, RSV2, RSV3: 1 bit each | |||
Must be 0 unless an extension is negotiated which defines meanings | Must be 0 unless an extension is negotiated which defines meanings | |||
for non-zero values | for non-zero values | |||
Opcode: 4 bits | Opcode: 4 bits | |||
Defines the interpretation of the payload data | Defines the interpretation of the payload data | |||
Payload length: 7 bits | Mask: 1 bit | |||
Defines whether the payload data is masked. If set to 1, a | ||||
masking key is present in Masking-key, and this is used to unmask | ||||
the payload data as per Section 4.3. All frames sent from client | ||||
to server have this bit set to 1. | ||||
Payload length: 7 bits, 7+16 bits, or 7+64 bits | ||||
The length of the payload: if 0-125, that is the payload length. | The length of the payload: if 0-125, that is the payload length. | |||
If 126, the following 2 bytes interpreted as a 16 bit unsigned | If 126, the following 2 bytes interpreted as a 16 bit unsigned | |||
integer are the payload length. If 127, the following 8 bytes | integer are the payload length. If 127, the following 8 bytes | |||
interpreted as a 64-bit unsigned integer (the high bit must be 0) | interpreted as a 64-bit unsigned integer (the most significant bit | |||
are the payload length. Multibyte length quantities are expressed | MUST be 0) are the payload length. Multibyte length quantities | |||
in network byte order. The payload length is the length of the | are expressed in network byte order. The payload length is the | |||
Extension data + the length of the Application Data. The length | length of the Extension data + the length of the Application data. | |||
of the Extension data may be zero, in which case the Payload | The length of the Extension data may be zero, in which case the | |||
length is the length of the Application data. | Payload length is the length of the Application data. The length | |||
of this field is always at least 7 bits. If the value of the | ||||
first 7 bits is 0-125, the length of this field is 7 bits. If the | ||||
value is 126, there exist 16 additional bits with a 16-bit length. | ||||
If the value is 127, there exist 64 additional bits with a 63-bit | ||||
length (the most significant bit MUST be 0). | ||||
Masking-key: 0 or 4 bytes | ||||
All frames sent from the client to the server are masked by a 32- | ||||
bit value that is contained within the frame. This field is | ||||
present if the Mask bit is set to 1, and is absent if the Mask bit | ||||
is set to 0. See Section 4.3 for further information on client- | ||||
to-server masking. | ||||
Payload data: n bytes | ||||
The payload data is defined as Extension Data concatenated with | ||||
Application Data. | ||||
Extension data: n bytes | Extension data: n bytes | |||
The extension data is 0 bytes unless there is a reserved op-code | The extension data is 0 bytes unless an extension has been | |||
or reserved bit present in the frame which indicates an extension | negotiated. Any extension MUST specify the length of the | |||
has been negotiated. Any extension MUST specify the length of the | extension data, or how that length may be calculated, and how the | |||
extension data, or how that length may be calculated, and its use | extension use MUST be negotiated during the handshake. If | |||
MUST be negotiated during the handshake. If present, the | present, the extension data is included in the total payload | |||
extension data is included in the total payload length. | length. | |||
Application data: n bytes | Application data: n bytes | |||
Arbitrary application data, taking up the remainder of the frame | Arbitrary application data, taking up the remainder of the frame | |||
after any extension data. The length of the Application data is | after any extension data. The length of the Application data is | |||
equal to the payload length minus the length of the Extension | equal to the payload length minus the length of the Extension | |||
data. | data. | |||
The base framing protocol is formally defined by the following ABNF | The base framing protocol is formally defined by the following ABNF | |||
[RFC5234]: | [RFC5234]: | |||
ws-frame = frame-fin | ws-frame = frame-fin | |||
frame-rsv1 | frame-rsv1 | |||
frame-rsv2 | frame-rsv2 | |||
frame-rsv3 | frame-rsv3 | |||
frame-opcode | frame-opcode | |||
frame-rsv4 | frame-masked | |||
frame-length | frame-payload-length | |||
frame-extension | [ frame-masking-key ] | |||
application-data; | frame-payload-data | |||
frame-fin = %x0 ; more frames of this message follow | frame-fin = %x0 ; more frames of this message follow | |||
/ %x1 ; final frame of message | / %x1 ; final frame of message | |||
frame-rsv1 = %x0 ; 1 bit, must be 0 | frame-rsv1 = %x0 ; 1 bit, MUST be 0 | |||
frame-rsv2 = %x0 ; 1 bit, must be 0 | frame-rsv2 = %x0 ; 1 bit, MUST be 0 | |||
frame-rsv3 = %x0 ; 1 bit, must be 0 | frame-rsv3 = %x0 ; 1 bit, MUST be 0 | |||
frame-opcode = %x0 ; continuation frame | frame-opcode = %x0 ; continuation frame | |||
/ %x1 ; connection close | / %x1 ; text frame | |||
/ %x2 ; ping | / %x2 ; binary frame | |||
/ %x3 ; pong | / %3-7 ; reserved for further non-control frames | |||
/ %x4 ; text frame | / %x8 ; connection close | |||
/ %x5 ; binary frame | / %x9 ; ping | |||
/ %x6-F ; reserved | / %xA ; pong | |||
/ %xB-F ; reserved for further control frames | ||||
frame-rsv4 = %x0 ; 1 bit, must be 0 | frame-masked = %x0 ; frame is not masked, no frame-masking-key | |||
= %x1 ; frame is masked, frame-masking-key present | ||||
frame-length = %x00-7D | frame-payload-length = %x00-7D | |||
/ %x7E frame-length-16 | / %x7E frame-payload-length-16 | |||
/ %x7F frame-length-63 | / %x7F frame-payload-length-63 | |||
frame-length-16 = %x0000-FFFF | frame-payload-length-16 = %x0000-FFFF | |||
frame-length-63 = %x0000000000000000-7FFFFFFFFFFFFFFF | frame-payload-length-63 = %x0000000000000000-7FFFFFFFFFFFFFFF | |||
frame-extension = *( %x00-FF ) ; to be defined later | frame-masking-key = <4>( %0x00-FF ) ; present only if frame-masked is 1 | |||
application-data = *( %x00-FF ) | frame-payload-data = (frame-masked-extension-data | |||
frame-masked-application-data) ; frame-masked 1 | ||||
/ (frame-unmasked-extension-data | ||||
frame-unmasked-application-data) ; frame-masked 0 | ||||
frame-masked-extension-data = *( %x00-FF ) ; to be defined later | ||||
frame-masked-application-data = *( %x00-FF ) | ||||
frame-unmasked-extension-data = *( %x00-FF ) ; to be defined later | ||||
frame-unmasked-application-data = *( %x00-FF ) | ||||
4.3. Client-to-Server Masking | ||||
The client MUST mask all frames sent to the server. A server MUST | ||||
close the connection upon receiving a frame with the MASK bit set to | ||||
0. In this case, a server MAY send a close frame with a status code | ||||
of 1002 (protocol error) as defined in Section 7.4.1. | ||||
A masked frame MUST have the field frame-masked set to 1, as defined | ||||
in Section 4.2. | ||||
The masking key is contained completely within the frame, as defined | ||||
in Section 4.2 as frame-masking-key. It is used to mask the payload | ||||
data defined in the same section as frame-payload-data, which | ||||
includes extension and application data. | ||||
The masking key is a 32-bit value chosen at random by the client. | ||||
The masking key MUST be derived from a strong source of entropy, and | ||||
the masking key for a given frame MUST NOT make it simple for a | ||||
server to predict the masking key for a subsequent frame. | ||||
The masking does not affect the length of the payload data. To | ||||
convert masked data into unmasked data, or vice versa, the following | ||||
algorithm is applied. The same algorithm applies regardless of the | ||||
direction of the translation - e.g. the same steps are applied to | ||||
mask the data as to unmask the data. | ||||
Octet i of the transformed data ("transformed-octet-i") is the XOR of | ||||
octet i of the original data ("original-octet-i") with octet i modulo | ||||
4 of the masking key ("masking-key-octet-j"): | ||||
j = i MOD 4 | ||||
transformed-octet-i = original-octet-i XOR masking-key-octet-j | ||||
When preparing a masked frame, the client MUST pick a fresh masking | ||||
key uniformly at random from the set of allowed 32-bit values. The | ||||
unpredictability of the masking-nonce is essential to prevent the | ||||
author of malicious application data from selecting the bytes that | ||||
appear on the wire. | ||||
The payload length, indicated in the framing as frame-payload-length, | ||||
does NOT include the length of the masking key. It is the length of | ||||
the payload data, e.g. the number of bytes following the masking key. | ||||
4.4. Fragmentation | 4.4. Fragmentation | |||
The primary purpose of fragmentation is to allow sending a message | The primary purpose of fragmentation is to allow sending a message | |||
that is of unknown size when the message is started without having to | that is of unknown size when the message is started without having to | |||
buffer that message. If messages couldn't be fragmented, then an | buffer that message. If messages couldn't be fragmented, then an | |||
endpoint would have to buffer the entire message so its length could | endpoint would have to buffer the entire message so its length could | |||
be counted before first byte is sent. With fragmentation, a server | be counted before first byte is sent. With fragmentation, a server | |||
or intermediary may choose a reasonable size buffer, and when the | or intermediary may choose a reasonable size buffer, and when the | |||
buffer is full write a fragment to the network. | buffer is full write a fragment to the network. | |||
skipping to change at page 20, line 22 | skipping to change at page 22, line 9 | |||
The following rules apply to fragmentation: | The following rules apply to fragmentation: | |||
o An unfragmented message consists of a single frame with the FIN | o An unfragmented message consists of a single frame with the FIN | |||
bit set and an opcode other than 0. | bit set and an opcode other than 0. | |||
o A fragmented message consists of a single frame with the FIN bit | o A fragmented message consists of a single frame with the FIN bit | |||
clear and an opcode other than 0, followed by zero or more frames | clear and an opcode other than 0, followed by zero or more frames | |||
with the FIN bit clear and the opcode set to 0, and terminated by | with the FIN bit clear and the opcode set to 0, and terminated by | |||
a single frame with the FIN bit set and an opcode of 0. Its | a single frame with the FIN bit set and an opcode of 0. Its | |||
content is the concatenation of the application data from each of | content is the concatenation of the application data (and any | |||
those frames in order. As an example, for a text message sent as | extension data that may be present) from each of those frames in | |||
three fragments, the first fragment would have an opcode of 0x4 | order. As an example, for a text message sent as three fragments, | |||
and a FIN bit clear, the second fragment would have an opcode of | the first fragment would have an opcode of 0x4 and a FIN bit | |||
0x0 and a FIN bit clear, and the third fragment would have an | clear, the second fragment would have an opcode of 0x0 and a FIN | |||
opcode of 0x0 and a FIN bit that is set. | bit clear, and the third fragment would have an opcode of 0x0 and | |||
a FIN bit that is set. | ||||
o Control frames MAY be injected in the middle of a fragmented | o Control frames MAY be injected in the middle of a fragmented | |||
message. Control frames themselves MUST NOT be fragmented. _Note: | message. Control frames themselves MUST NOT be fragmented. | |||
if control frames could not be interjected, the latency of a ping, | ||||
for example, would be very long if behind a large message. As | o An endpoint MUST be capable of handling control frames in the | |||
such, an endpoint MUST be capable of handling control frames in | middle of a fragmented message. | |||
the middle of a fragmented message._ | ||||
o _Note: if control frames could not be interjected, the latency of | ||||
a ping, for example, would be very long if behind a large message. | ||||
Hence, the requirement of handling control frames in the middle of | ||||
a fragmented message._ | ||||
o A sender MAY create fragments of any size for non control | o A sender MAY create fragments of any size for non control | |||
messages. | messages. | |||
o Clients and servers MUST support receiving both fragmented and | o Clients and servers MUST support receiving both fragmented and | |||
unfragmented messages. | unfragmented messages. | |||
o An intermediary MAY change the fragmentation of a message if the | o As control frames cannot be fragmented, an intermediary MUST NOT | |||
message uses only opcode and reserved bit values known to the | attempt to change the fragmentation of a control frame. | |||
intermediary. | ||||
o An intermediary MUST NOT change the fragmentation of a message if | ||||
any reserved bit values are used and the meaning of these values | ||||
is not known to the intermediary. | ||||
o An intermediary MUST NOT change the fragmentation of any message | ||||
in the context of a connection where extensions have been | ||||
negotiated and the intermediary is not aware of the semantics of | ||||
the negotiated extensions. | ||||
o As a consequence of these rules, all fragments of a message are of | o As a consequence of these rules, all fragments of a message are of | |||
the same type, as set by the first fragment's opcode. Since | the same type, as set by the first fragment's opcode. Since | |||
Control frames cannot be fragmented, the type for all fragments in | Control frames cannot be fragmented, the type for all fragments in | |||
a message MUST be either text or binary, or one of the reserved | a message MUST be either text or binary, or one of the reserved | |||
opcodes. | opcodes. | |||
4.5. Control Frames | 4.5. Control Frames | |||
Control frames have opcodes of 0x01 (Close), 0x02 (Ping), or 0x03 | Control frames are identified by opcodes where the most significant | |||
(Pong). Control frames are used to communicate state about the | bit of the opcode is 1. Currently defined opcodes for control frames | |||
websocket. Control frames can be interjected in the middle of a | include 0x8 (Close), 0x9 (Ping), and 0xA (Pong). Opcodes 0xB-0xF are | |||
fragmented message. | reserved for further control frames yet to be defined. | |||
All control frames MUST be 125 bytes or less in length and MUST NOT | Control frames are used to communicate state about the websocket. | |||
be fragmented. | Control frames can be interjected in the middle of a fragmented | |||
message. | ||||
All control frames MUST have a payload length of 125 bytes or less | ||||
and MUST NOT be fragmented. | ||||
4.5.1. Close | 4.5.1. Close | |||
The Close message contains an opcode of 0x01. | The Close message contains an opcode of 0x8. | |||
The Close message MAY contain a body (the "application data" portion | The Close message MAY contain a body (the "application data" portion | |||
of the frame) that indicates a reason for closing, such as an | of the frame) that indicates a reason for closing, such as an | |||
endpoint shutting down, an endpoint having received a message too | endpoint shutting down, an endpoint having received a message too | |||
large, or an endpoint having received a message that does not conform | large, or an endpoint having received a message that does not conform | |||
to the format expected by the other endpoint. If there is a body, | to the format expected by the other endpoint. If there is a body, | |||
the first two bytes of the body MUST be a 2-byte integer (in network | the first two bytes of the body MUST be a 2-byte integer (in network | |||
byte order) representing a status code defined in Section 7.4. | byte order) representing a status code defined in Section 7.4. | |||
Following the 2-byte integer the body MAY contain UTF-8 encoded data, | Following the 2-byte integer the body MAY contain UTF-8 encoded data, | |||
the interpretation of which is not defined by this specification. | the interpretation of which is not defined by this specification. | |||
This data is not necessarily human readable, but may be useful for | ||||
debugging or passing information relevant to the script that opened | ||||
the connection. | ||||
The application MUST NOT send any more data messages after sending a | The application MUST NOT send any more data frames after sending a | |||
close message. | close message. | |||
If an endpoint receives a Close message and that endpoint did not | If an endpoint receives a Close message and that endpoint did not | |||
previously send a Close message, the endpoint MUST send a Close | previously send a Close message, the endpoint MUST send a Close | |||
message in response. It SHOULD do so as soon as is practical. | message in response. It SHOULD do so as soon as is practical. | |||
After both sending and receiving a close message, an endpoint | After both sending and receiving a close message, an endpoint | |||
considers the websocket connection closed, and SHOULD close the | considers the websocket connection closed, and SHOULD close the | |||
underlying TCP connection. | underlying TCP connection. | |||
If a client and server both send a Close message at the same time, | If a client and server both send a Close message at the same time, | |||
both endpoints will have sent and received a Close message and should | both endpoints will have sent and received a Close message and should | |||
consider the websocket connection closed and close the underlying TCP | consider the websocket connection closed and close the underlying TCP | |||
connection. | connection. | |||
4.5.2. Ping | 4.5.2. Ping | |||
The Ping message contains an opcode of 0x02. | The Ping message contains an opcode of 0x9. | |||
Upon receipt of a Ping message, an endpoint MUST send a Pong message | Upon receipt of a Ping message, an endpoint MUST send a Pong message | |||
in response. It SHOULD do so as soon as is practical. The message | in response. It SHOULD do so as soon as is practical. The message | |||
bodies of the Ping and Pong MUST be the same. | bodies (i.e. both the Extension data (if any) and the Application | |||
data) of the Ping and Pong MUST be the same. | ||||
An endpoint MAY send a Ping message any time after the connection is | ||||
established and before the connection is closed. NOTE: A ping | ||||
message may serve either as a keepalive, or to verify that the remote | ||||
endpoint is still responsive. | ||||
4.5.3. Pong | 4.5.3. Pong | |||
The Pong message contains an opcode of 0x03. | The Pong message contains an opcode of 0xA. | |||
Upon receipt of a Ping message, an endpoint MUST send a Pong message | Upon receipt of a Ping message, an endpoint MUST send a Pong message | |||
in response. It SHOULD do so as soon as is practical. The message | in response. It SHOULD do so as soon as is practical. The message | |||
bodies of the Ping and Pong MUST be the same. A Pong is issued only | bodies (i.e. both the Extension data (if any) and the Application | |||
in response to the most recent Ping. | data) of the Ping and Pong MUST be the same. In the case multiple | |||
Pings have been received, a Pong MUST be issued only in response to | ||||
the most recent Ping. | ||||
A Pong message MAY be sent unsolicited. This serves as a | ||||
unidirectional heartbeat. A response to an unsolicited pong is not | ||||
expected. | ||||
4.6. Data Frames | 4.6. Data Frames | |||
All frame types not listed in Section 4.5 are data frames, which | Data frames (e.g. non control frames) are identified by opcodes where | |||
transport application-layer data. The opcode determines the | the most significant bit of the opcode is 0. Currently defined | |||
interpretation of the application data: | opcodes for data frames include 0x1 (Text), 0x2 (Binary). Opcodes | |||
0x3-0x7 are reserved for further non-control frames yet to be | ||||
defined. | ||||
Data frames carry application-layer or extension-layer data. The | ||||
opcode determines the interpretation of the data: | ||||
Text | Text | |||
The payload data is text data encoded as UTF-8. | The payload data is text data encoded as UTF-8. | |||
Binary | Binary | |||
The payload data is arbitrary binary data whose interpretation is | The payload data is arbitrary binary data whose interpretation is | |||
solely up to the application layer. | solely up to the application layer. | |||
4.7. Examples | 4.7. Examples | |||
_This section is non-normative._ | _This section is non-normative._ | |||
o A single-frame text message | o A single-frame unmasked text message | |||
* 0x84 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains "Hello") | * 0x81 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains "Hello") | |||
o A fragmented text message | o A single-frame masked text message | |||
* 0x04 0x03 0x48 0x65 0x6c (contains "Hel") | * 0x81 0x85 0x37 0xfa 0x21 0x3d 0x7f 0x9f 0x4d 0x51 0x58 | |||
(contains "Hello") | ||||
o A fragmented unmasked text message | ||||
* 0x01 0x03 0x48 0x65 0x6c (contains "Hel") | ||||
* 0x80 0x02 0x6c 0x6f (contains "lo") | * 0x80 0x02 0x6c 0x6f (contains "lo") | |||
o Ping request and response | o Ping request and response | |||
* 0x82 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains a body of "Hello", | * 0x89 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains a body of "Hello", | |||
but the contents of the body are arbitrary) | but the contents of the body are arbitrary) | |||
* 0x83 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains a body of "Hello", | * 0x8a 0x05 0x48 0x65 0x6c 0x6c 0x6f (contains a body of "Hello", | |||
matching the body of the ping) | matching the body of the ping) | |||
o 256 bytes binary message in a single frame | o 256 bytes binary message in a single unmasked frame | |||
* 0x85 0x7E 0x0100 [256 bytes of binary data] | * 0x82 0x7E 0x0100 [256 bytes of binary data] | |||
o 64KiB binary message in a single frame | o 64KiB binary message in a single unmasked frame | |||
* 0x85 0x7F 0x0000000000010000 [65536 bytes of binary data] | * 0x82 0x7F 0x0000000000010000 [65536 bytes of binary data] | |||
4.8. Extensibility | 4.8. Extensibility | |||
The protocol is designed to allow for extensions, which will add | The protocol is designed to allow for extensions, which will add | |||
capabilities to the base protocols. The endpoints of a connection | capabilities to the base protocols. The endpoints of a connection | |||
MUST negotiate the use of any extensions during the handshake. This | MUST negotiate the use of any extensions during the handshake. This | |||
specification provides opcodes 0x6 through 0xF, the extension data | specification provides opcodes 0x3 through 0x7 and 0xB through 0xF, | |||
field, and the frame-rsv1, frame-rsv2, frame-rsv3, and frame-rsv4 | the extension data field, and the frame-rsv1, frame-rsv2, and frame- | |||
bits of the frame header for use by extensions. The negotiation of | rsv3 bits of the frame header for use by extensions. The negotiation | |||
extensions is discussed in further detail in Section 8.1. Below are | of extensions is discussed in further detail in Section 8.1. Below | |||
some anticipated uses of extensions. This list is neither complete | are some anticipated uses of extensions. This list is neither | |||
nor proscriptive. | complete nor proscriptive. | |||
o Extension data may be placed in the payload before the application | o Extension data may be placed in the payload before the application | |||
data. | data. | |||
o Reserved bits can be allocated for per-frame needs. | o Reserved bits can be allocated for per-frame needs. | |||
o Reserved opcode values can be defined. | o Reserved opcode values can be defined. | |||
o Reserved bits can be allocated to the opcode field if more opcode | o Reserved bits can be allocated to the opcode field if more opcode | |||
values are needed. | values are needed. | |||
skipping to change at page 24, line 15 | skipping to change at page 27, line 15 | |||
5. Opening Handshake | 5. Opening Handshake | |||
5.1. Client Requirements | 5.1. Client Requirements | |||
User agents running in controlled environments, e.g. browsers on | User agents running in controlled environments, e.g. browsers on | |||
mobile handsets tied to specific carriers, may offload the management | mobile handsets tied to specific carriers, may offload the management | |||
of the connection to another agent on the network. In such a | of the connection to another agent on the network. In such a | |||
situation, the user agent for the purposes of conformance is | situation, the user agent for the purposes of conformance is | |||
considered to include both the handset software and any such agents. | considered to include both the handset software and any such agents. | |||
When the user agent is to *establish a WebSocket connection* to a | When the user agent is to *establish a WebSocket connection* given | |||
WebSocket URI /uri/, it must meet the following requirements. In the | either a WebSocket URI /uri/ or the constituent components of a URI | |||
following text, we will use terms from Section 3 such as "/host/" and | as specified in Section 11, it MUST meet the following requirements. | |||
"/secure/ flag" as defined in that section. | In the following text, we will use terms from Section 3 such as | |||
"/host/" and "/secure/ flag" as defined in that section. | ||||
1. The WebSocket URI and its components MUST be valid according to | 1. The WebSocket URI and its components derived by applying the | |||
steps defined in Section 3.3, or if the following algorithm was | ||||
supplied with the constituent components as defined in Section 11 | ||||
then those components provided, MUST be valid according to | ||||
Section 3.3. If any of the requirements are not met, the client | Section 3.3. If any of the requirements are not met, the client | |||
MUST fail the WebSocket connection and abort these steps. | MUST fail the WebSocket connection and abort these steps. | |||
2. If the user agent already has a WebSocket connection to the | 2. If the user agent already has a WebSocket connection to the | |||
remote host (IP address) identified by /host/, even if known by | remote host (IP address) identified by /host/ and port /port/ | |||
another name, the user agent MUST wait until that connection has | pair, even if the remote host is known by another name, the user | |||
been established or for that connection to have failed. There | agent MUST wait until that connection has been established or for | |||
MUST be no more than one connection in a CONNECTING state. If | that connection to have failed. There MUST be no more than one | |||
multiple connections to the same IP address are attempted | connection in a CONNECTING state. If multiple connections to the | |||
simultaneously, the user agent MUST serialize them so that there | same IP address are attempted simultaneously, the user agent MUST | |||
is no more than one connection at a time running through the | serialize them so that there is no more than one connection at a | |||
following steps. | time running through the following steps. | |||
If the user agent cannot determine the IP address of the remote | If the user agent cannot determine the IP address of the remote | |||
host (for example because all communication is being done through | host (for example because all communication is being done through | |||
a proxy server that performs DNS queries itself), then the user | a proxy server that performs DNS queries itself), then the user | |||
agent MUST assume for the purposes of this step that each host | agent MUST assume for the purposes of this step that each host | |||
name refers to a distinct remote host, but should instead limit | name refers to a distinct remote host, but should instead limit | |||
the total number of simultaneous connections that are not | the total number of simultaneous connections that are not | |||
established to a reasonably low number (e.g., in a Web browser, | established to a reasonably low number (e.g., in a Web browser, | |||
to the number of tabs the user has open). | to the number of tabs the user has open). | |||
NOTE: This makes it harder for a script to perform a denial of | NOTE: This makes it harder for a script to perform a denial of | |||
service attack by just opening a large number of WebSocket | service attack by just opening a large number of WebSocket | |||
connections to a remote host. A server can further reduce the | connections to a remote host. A server can further reduce the | |||
load on itself when attacked by making use of this by pausing | load on itself when attacked by making use of this by pausing | |||
before closing the connection, as that will reduce the rate at | before closing the connection, as that will reduce the rate at | |||
which the client reconnects. | which the client reconnects. | |||
NOTE: There is no limit to the number of established WebSocket | NOTE: There is no limit to the number of established WebSocket | |||
connections a user agent can have with a single remote host. | connections a user agent can have with a single remote host. | |||
Servers can refuse to connect users with an excessive number of | Servers can refuse to accept connections from hosts with an | |||
connections, or disconnect resource-hogging users when suffering | excessive number of existing connections, or disconnect resource- | |||
high load. | hogging connections when suffering high load. | |||
3. _Proxy Usage_: If the user agent is configured to use a proxy | 3. _Proxy Usage_: If the user agent is configured to use a proxy | |||
when using the WebSocket protocol to connect to host /host/ | when using the WebSocket protocol to connect to host /host/ | |||
and/or port /port/, then the user agent SHOULD connect to that | and/or port /port/, then the user agent SHOULD connect to that | |||
proxy and ask it to open a TCP connection to the host given by | proxy and ask it to open a TCP connection to the host given by | |||
/host/ and the port given by /port/. | /host/ and the port given by /port/. | |||
EXAMPLE: For example, if the user agent uses an HTTP proxy for | EXAMPLE: For example, if the user agent uses an HTTP proxy for | |||
all traffic, then if it was to try to connect to port 80 on | all traffic, then if it was to try to connect to port 80 on | |||
server example.com, it might send the following lines to the | server example.com, it might send the following lines to the | |||
skipping to change at page 25, line 39 | skipping to change at page 28, line 43 | |||
the port given by /port/. | the port given by /port/. | |||
NOTE: Implementations that do not expose explicit UI for | NOTE: Implementations that do not expose explicit UI for | |||
selecting a proxy for WebSocket connections separate from other | selecting a proxy for WebSocket connections separate from other | |||
proxies are encouraged to use a SOCKS proxy for WebSocket | proxies are encouraged to use a SOCKS proxy for WebSocket | |||
connections, if available, or failing that, to prefer the proxy | connections, if available, or failing that, to prefer the proxy | |||
configured for HTTPS connections over the proxy configured for | configured for HTTPS connections over the proxy configured for | |||
HTTP connections. | HTTP connections. | |||
For the purpose of proxy autoconfiguration scripts, the URI to | For the purpose of proxy autoconfiguration scripts, the URI to | |||
pass the function must be constructed from /host/, /port/, | pass the function MUST be constructed from /host/, /port/, | |||
/resource name/, and the /secure/ flag using the steps to | /resource name/, and the /secure/ flag using the steps to | |||
construct a WebSocket URI. | construct a WebSocket URI as given in Section 3.2. | |||
NOTE: The WebSocket protocol can be identified in proxy | NOTE: The WebSocket protocol can be identified in proxy | |||
autoconfiguration scripts from the scheme ("ws:" for unencrypted | autoconfiguration scripts from the scheme ("ws:" for unencrypted | |||
connections and "wss:" for encrypted connections). | connections and "wss:" for encrypted connections). | |||
4. If the connection could not be opened, either because a direct | 4. If the connection could not be opened, either because a direct | |||
connection failed or because any proxy used returned an error, | connection failed or because any proxy used returned an error, | |||
then the user agent MUST fail the WebSocket connection and abort | then the user agent MUST fail the WebSocket connection and abort | |||
the connection attempt. | the connection attempt. | |||
5. If /secure/ is true, the user agent MUST perform a TLS handshake | 5. If /secure/ is true, the user agent MUST perform a TLS handshake | |||
over the connection. If this fails (e.g. the server's | over the connection [RFC2818]. If this fails (e.g. the server's | |||
certificate could not be verified), then the user agent MUST fail | certificate could not be verified), then the user agent MUST fail | |||
the WebSocket connection and abort the connection. Otherwise, | the WebSocket connection and abort the connection. Otherwise, | |||
all further communication on this channel MUST run through the | all further communication on this channel MUST run through the | |||
encrypted tunnel. [RFC2246] | encrypted tunnel. [RFC5246] | |||
User agents MUST use the Server Name Indication extension in the | User agents MUST use the Server Name Indication extension in the | |||
TLS handshake. [RFC4366] | TLS handshake. [RFC6066] | |||
Once a connection to the server has been established (including a | Once a connection to the server has been established (including a | |||
connection via a proxy or over a TLS-encrypted tunnel), the client | connection via a proxy or over a TLS-encrypted tunnel), the client | |||
MUST send a handshake to the server. The handshake consists of an | MUST send a handshake to the server. The handshake consists of an | |||
HTTP upgrade request, along with a list of required and optional | HTTP upgrade request, along with a list of required and optional | |||
headers. The requirements for this handshake are as follows. | headers. The requirements for this handshake are as follows. | |||
1. The handshake must be a valid HTTP request as specified by | 1. The handshake MUST be a valid HTTP request as specified by | |||
[RFC2616]. | [RFC2616]. | |||
2. The Method of the request MUST be GET and the HTTP version MUST | 2. The Method of the request MUST be GET and the HTTP version MUST | |||
be at least 1.1. | be at least 1.1. | |||
For example, if the WebSocket URI is "ws://example.com/chat", | For example, if the WebSocket URI is "ws://example.com/chat", | |||
The first line sent SHOULD be "GET /chat HTTP/1.1" | The first line sent should be "GET /chat HTTP/1.1" | |||
3. The request must contain a "Request-URI" as part of the GET | 3. The request MUST contain a "Request-URI" as part of the GET | |||
method. This MUST match the /resource name/ Section 3. | method. This MUST match the /resource name/ Section 3. | |||
4. The request MUST contain a "Host" header whose value is equal to | 4. The request MUST contain a "Host" header whose value is equal to | |||
the authority component of the WebSocket URI. | /host/ | |||
5. The request MUST contain an "Upgrade" header whose value is | 5. The request MUST contain an "Upgrade" header whose value is | |||
equal to "websocket". | equal to "websocket". | |||
6. The request MUST contain a "Connection" header whose value MUST | 6. The request MUST contain a "Connection" header whose value MUST | |||
include the "Upgrade" token. | include the "Upgrade" token. | |||
7. The request MUST include a header with the name "Sec-WebSocket- | 7. The request MUST include a header with the name "Sec-WebSocket- | |||
Key". The value of this header MUST be a nonce consisting of a | Key". The value of this header MUST be a nonce consisting of a | |||
randomly selected 16-byte value that has been base64-encoded | randomly selected 16-byte value that has been base64-encoded | |||
[RFC3548]. The nonce MUST be randomly selected randomly for | [RFC3548]. The nonce MUST be selected randomly for each | |||
each connection. | connection. | |||
NOTE: As an example, if the randomly selected value was the | NOTE: As an example, if the randomly selected value was the | |||
sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 | sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 | |||
0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the header | 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the header | |||
would be "AQIDBAUGBwgJCgsMDQ4PEC==" | would be "AQIDBAUGBwgJCgsMDQ4PEC==" | |||
8. The request MUST include a header with the name "Sec-WebSocket- | 8. The request MUST include a header with the name "Sec-WebSocket- | |||
Origin" if the request is coming from a browser client. If the | Origin" if the request is coming from a browser client. If the | |||
connection is from a non-browser client, the request MAY include | connection is from a non-browser client, the request MAY include | |||
this header if the semantics of that client match the use-case | this header if the semantics of that client match the use-case | |||
skipping to change at page 27, line 22 | skipping to change at page 30, line 26 | |||
which the code establishing the connection is running, and MUST | which the code establishing the connection is running, and MUST | |||
be lower-case. The value MUST NOT contain letters in the range | be lower-case. The value MUST NOT contain letters in the range | |||
U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL | U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL | |||
LETTER Z) [I-D.ietf-websec-origin]. | LETTER Z) [I-D.ietf-websec-origin]. | |||
As an example, if code is running on www.example.com attempting | As an example, if code is running on www.example.com attempting | |||
to establish a connection to ww2.example.com, the value of the | to establish a connection to ww2.example.com, the value of the | |||
header would be "http://www.example.com". | header would be "http://www.example.com". | |||
9. The request MUST include a header with the name "Sec-WebSocket- | 9. The request MUST include a header with the name "Sec-WebSocket- | |||
Version". The value of this header must be 6. | Version". The value of this header MUST be 7. | |||
10. The request MAY include a header with the name "Sec-WebSocket- | 10. The request MAY include a header with the name "Sec-WebSocket- | |||
Protocol". If present, this value indicates the subprotocol(s) | Protocol". If present, this value indicates the subprotocol(s) | |||
the client wishes to speak. The elements that comprise this | the client wishes to speak. The elements that comprise this | |||
value MUST be non-empty strings with characters in the range | value MUST be non-empty strings with characters in the range | |||
U+0021 to U+007E and MUST all be unique. The ABNF for the value | U+0021 to U+007E and MUST all be unique strings. The ABNF for | |||
of this header is 1#(token | quoted-string), where the | the value of this header is 1#(token | quoted-string), where the | |||
definitions of constructs and rules are as given in [RFC2616]. | definitions of constructs and rules are as given in [RFC2616]. | |||
11. The request MAY include a header with the name "Sec-WebSocket- | 11. The request MAY include a header with the name "Sec-WebSocket- | |||
Extensions". If present, this value indicates the protocol- | Extensions". If present, this value indicates the protocol- | |||
level extension(s) the client wishes to speak. The | level extension(s) the client wishes to speak. The | |||
interpretation and format of this header is described in | interpretation and format of this header is described in | |||
Section 8.1. | Section 8.1. | |||
12. The request MAY include headers associated with sending cookies, | 12. The request MAY include headers associated with sending cookies, | |||
as defined by the appropriate specifications | as defined by the appropriate specifications | |||
[I-D.ietf-httpstate-cookie]. | [I-D.ietf-httpstate-cookie]. | |||
Once the client's opening handshake has been sent, the client MUST | Once the client's opening handshake has been sent, the client MUST | |||
wait for a response from the server before sending any further data. | wait for a response from the server before sending any further data. | |||
The client MUST validate the server's response as follows: | The client MUST validate the server's response as follows: | |||
o If the status code received from the server is not 101, the client | o If the status code received from the server is not 101, the client | |||
MUST fail the WebSocket connection. | handles the response per HTTP procedures. Otherwise, proceed as | |||
follows. | ||||
o If the response lacks an Upgrade header or the Upgrade header | o If the response lacks an Upgrade header or the Upgrade header | |||
contains a value that is not an ASCII case-insensitive match for | contains a value that is not an ASCII case-insensitive match for | |||
the value "websocket", the client MUST fail the WebSocket | the value "websocket", the client MUST fail the WebSocket | |||
connection. | connection. | |||
o If the response lacks a Connection header or the Connection header | o If the response lacks a Connection header or the Connection header | |||
contains a value that is not an ASCII case-insensitive match for | contains a value that is not an ASCII case-insensitive match for | |||
the value "Upgrade", the client MUST fail the WebSocket | the value "Upgrade", the client MUST fail the WebSocket | |||
connection. | connection. | |||
o If the response lacks a Sec-WebSocket-Accept header or the Sec- | o If the response lacks a Sec-WebSocket-Accept header or the Sec- | |||
WebSocket-Accept contains a value other than the base64-encoded | WebSocket-Accept contains a value other than the base64-encoded | |||
SHA-1 of the concatenation of the Sec-WebSocket-Key (as a string, | SHA-1 of the concatenation of the Sec-WebSocket-Key (as a string, | |||
not base64-decoded) with the string "258EAFA5-E914-47DA-95CA- | not base64-decoded) with the string "258EAFA5-E914-47DA-95CA- | |||
C5AB0DC85B11", the client MUST fail the WebSocket connection. | C5AB0DC85B11", the client MUST fail the WebSocket connection. | |||
Where the algorithm above requires that a user agent fail the | Where the algorithm above requires that a user agent fail the | |||
WebSocket connection, the user agent may first read an arbitrary | WebSocket connection, the user agent MAY first read an arbitrary | |||
number of further bytes from the connection (and then discard them) | number of further bytes from the connection (and then discard them) | |||
before actually *failing the WebSocket connection*. Similarly, if a | before actually *failing the WebSocket connection*. Similarly, if a | |||
user agent can show that the bytes read from the connection so far | user agent can show that the bytes read from the connection so far | |||
are such that there is no subsequent sequence of bytes that the | are such that there is no subsequent sequence of bytes that the | |||
server can send that would not result in the user agent being | server can send that would not result in the user agent being | |||
required to *fail the WebSocket connection*, the user agent may | required to *fail the WebSocket connection*, the user agent MAY | |||
immediately *fail the WebSocket connection* without waiting for those | immediately *fail the WebSocket connection* without waiting for those | |||
bytes. | bytes. | |||
NOTE: The previous paragraph is intended to make it conforming for | NOTE: The previous paragraph is intended to make it conforming for | |||
user agents to implement the algorithm in subtly different ways that | user agents to implement the algorithm in subtly different ways that | |||
are equivalent in all ways except that they terminate the connection | are equivalent in all ways except that they terminate the connection | |||
at earlier or later points. For example, it enables an | at earlier or later points. For example, it enables an | |||
implementation to buffer the entire handshake response before | implementation to buffer the entire handshake response before | |||
checking it, or to verify each field as it is received rather than | checking it, or to verify each field as it is received rather than | |||
collecting all the fields and then checking them as a block. | collecting all the fields and then checking them as a block. | |||
5.2. Server-side requirements | 5.2. Server-side requirements | |||
_This section only applies to servers._ | _This section only applies to servers._ | |||
Servers may offload the management of the connection to other agents | Servers MAY offload the management of the connection to other agents | |||
on the network, for example load balancers and reverse proxies. In | on the network, for example load balancers and reverse proxies. In | |||
such a situation, the server for the purposes of conformance is | such a situation, the server for the purposes of conformance is | |||
considered to include all parts of the server-side infrastructure | considered to include all parts of the server-side infrastructure | |||
from the first device to terminate the TCP connection all the way to | from the first device to terminate the TCP connection all the way to | |||
the server that processes requests and sends responses. | the server that processes requests and sends responses. | |||
EXAMPLE: For example, a data center might have a server that responds | EXAMPLE: For example, a data center might have a server that responds | |||
to WebSocket requests with an appropriate handshake, and then passes | to WebSocket requests with an appropriate handshake, and then passes | |||
the connection to another server to actually process the data frames. | the connection to another server to actually process the data frames. | |||
For the purposes of this specification, the "server" is the | For the purposes of this specification, the "server" is the | |||
skipping to change at page 29, line 14 | skipping to change at page 32, line 17 | |||
5.2.1. Reading the client's opening handshake | 5.2.1. Reading the client's opening handshake | |||
When a client starts a WebSocket connection, it sends its part of the | When a client starts a WebSocket connection, it sends its part of the | |||
opening handshake. The server must parse at least part of this | opening handshake. The server must parse at least part of this | |||
handshake in order to obtain the necessary information to generate | handshake in order to obtain the necessary information to generate | |||
the server part of the handshake. | the server part of the handshake. | |||
The client handshake consists of the following parts. If the server, | The client handshake consists of the following parts. If the server, | |||
while reading the handshake, finds that the client did not send a | while reading the handshake, finds that the client did not send a | |||
handshake that matches the description below, the server must abort | handshake that matches the description below, the server MUST abort | |||
the WebSocket connection. | the WebSocket connection. | |||
1. An HTTP/1.1 or higher GET request, including a "Request-URI" | 1. An HTTP/1.1 or higher GET request, including a "Request-URI" | |||
[RFC2616] that should be interpreted as a /resource name/ | [RFC2616] that should be interpreted as a /resource name/ | |||
Section 3. | Section 3. | |||
2. A "Host" header containing the server's authority. | 2. A "Host" header containing the server's authority. | |||
3. A "Sec-WebSocket-Key" header with a base64-encoded value that, | 3. A "Sec-WebSocket-Key" header with a base64-encoded value that, | |||
when decoded, is 16 bytes in length. | when decoded, is 16 bytes in length. | |||
4. A "Sec-WebSocket-Version" header, with a value of 6. | 4. A "Sec-WebSocket-Version" header, with a value of 7. | |||
5. Optionally, a "Sec-WebSocket-Origin" header. This header is sent | 5. Optionally, a "Sec-WebSocket-Origin" header. This header is sent | |||
by all browser clients. A connection attempt lacking this header | by all browser clients. A connection attempt lacking this header | |||
SHOULD NOT be interpreted as coming from a browser client. | SHOULD NOT be interpreted as coming from a browser client. | |||
6. Optionally, a "Sec-WebSocket-Protocol header, with a list of | 6. Optionally, a "Sec-WebSocket-Protocol" header, with a list of | |||
values indicating which protocols the client would like to speak, | values indicating which protocols the client would like to speak, | |||
ordered by preference. | ordered by preference. | |||
7. Optionally, a "Sec-WebSocket-Extensions" header, with a list of | 7. Optionally, a "Sec-WebSocket-Extensions" header, with a list of | |||
values indicating which extensions the client would like to | values indicating which extensions the client would like to | |||
speak. The interpretation of this header is discussed in | speak. The interpretation of this header is discussed in | |||
Section 8.1. | Section 8.1. | |||
8. Optionally, other headers, such as those used to send cookies to | 8. Optionally, other headers, such as those used to send cookies to | |||
a server. Unknown headers MUST be ignored. | a server. Unknown headers MUST be ignored. | |||
5.2.2. Sending the server's opening handshake | 5.2.2. Sending the server's opening handshake | |||
When a client establishes a WebSocket connection to a server, the | When a client establishes a WebSocket connection to a server, the | |||
server must complete the following steps to accept the connection and | server MUST complete the following steps to accept the connection and | |||
send the server's opening handshake. | send the server's opening handshake. | |||
1. If the server supports encryption, perform a TLS handshake over | 1. If the server supports encryption, perform a TLS handshake over | |||
the connection. If this fails (e.g. the client indicated a host | the connection. If this fails (e.g. the client indicated a host | |||
name in the extended client hello "server_name" extension that | name in the extended client hello "server_name" extension that | |||
the server does not host), then close the connection; otherwise, | the server does not host), then close the connection; otherwise, | |||
all further communication for the connection (including the | all further communication for the connection (including the | |||
server handshake) must run through the encrypted tunnel. | server handshake) MUST run through the encrypted tunnel. | |||
[RFC2246] | [RFC5246] | |||
2. Establish the following information: | 2. Establish the following information: | |||
/origin/ | /origin/ | |||
The |Sec-WebSocket-Origin| header in the client's handshake | The |Sec-WebSocket-Origin| header in the client's handshake | |||
indicates the origin of the script establishing the | indicates the origin of the script establishing the | |||
connection. The origin is serialized to ASCII and converted | connection. The origin is serialized to ASCII and converted | |||
to lowercase. The server MAY use this information as part of | to lowercase. The server MAY use this information as part of | |||
a determination of whether to accept the incoming connection. | a determination of whether to accept the incoming connection. | |||
If the server does not validate the origin, it will accept | ||||
connections from anywhere. For more detail, refer to | ||||
Section 9. | ||||
/key/ | /key/ | |||
The |Sec-WebSocket-Key| header in the client's handshake | The |Sec-WebSocket-Key| header in the client's handshake | |||
includes a base64-encoded value that, if decoded, is 16 bytes | includes a base64-encoded value that, if decoded, is 16 bytes | |||
in length. This (encoded) value is used in the creation of | in length. This (encoded) value is used in the creation of | |||
the server's handshake to indicate an acceptance of the | the server's handshake to indicate an acceptance of the | |||
connection. It is not necessary for the server to base64- | connection. It is not necessary for the server to base64- | |||
decode the Sec-WebSocket-Key value. | decode the Sec-WebSocket-Key value. | |||
/version/ | /version/ | |||
The |Sec-WebSocket-Version| header in the client's handshake | The |Sec-WebSocket-Version| header in the client's handshake | |||
includes the version of the WebSocket protocol the client is | includes the version of the WebSocket protocol the client is | |||
attempting to communicate with. If this version does not | attempting to communicate with. If this version does not | |||
match a version understood by the server, the server MUST | match a version understood by the server, the server MUST | |||
abort the WebSocket connection. The server MAY send a non-200 | abort the WebSocket connection. The server MAY send a non-200 | |||
response code with a |Sec-WebSocket-Version| header indicating | response code with a |Sec-WebSocket-Version| header indicating | |||
the version(s) the server is capable of understanding along | the version(s) the server is capable of understanding. | |||
with this non-200 response code. | ||||
/resource name/ | /resource name/ | |||
An identifier for the service provided by the server. If the | An identifier for the service provided by the server. If the | |||
server provides multiple services, then the value should be | server provides multiple services, then the value should be | |||
derived from the resource name given in the client's handshake | derived from the resource name given in the client's handshake | |||
from the Request-URI [RFC2616] of the GET method. | from the Request-URI [RFC2616] of the GET method. | |||
/subprotocol/ | /subprotocol/ | |||
A (possibly empty) list representing the subprotocol the | Either a single value or null, representing the subprotocol | |||
server is ready to use. If the server supports multiple | the server is ready to use. If the server supports multiple | |||
subprotocols, then the value should be derived from the | subprotocols, then the value MUST be derived from the client's | |||
client's handshake, specifically by selecting one of the | handshake, specifically by selecting one of the values from | |||
values from the "Sec-WebSocket-Protocol" field. The absence | the "Sec-WebSocket-Protocol" field. The absence of such a | |||
of such a field is equivalent to the null value. The empty | field is equivalent to the null value. The empty string is | |||
string is not the same as the null value for these purposes. | not the same as the null value for these purposes, and is not | |||
a legal value for this field. The ABNF for the value of this | ||||
header is (token | quoted-string), where the definitions of | ||||
constructs and rules are as given in [RFC2616]. | ||||
/extensions/ | /extensions/ | |||
A (possibly empty) list representing the protocol-level | A (possibly empty) list representing the protocol-level | |||
extensions the server is ready to use. If the server supports | extensions the server is ready to use. If the server supports | |||
multiple extensions, then the value should be derived from the | multiple extensions, then the value MUST be derived from the | |||
client's handshake, specifically by selecting one or more of | client's handshake, specifically by selecting one or more of | |||
the values from the "Sec-WebSocket-Extensions" field. The | the values from the "Sec-WebSocket-Extensions" field. The | |||
absence of such a field is equivalent to the null value. The | absence of such a field is equivalent to the null value. The | |||
empty string is not the same as the null value for these | empty string is not the same as the null value for these | |||
purposes. Extensions not listed by the client MUST NOT be | purposes. Extensions not listed by the client MUST NOT be | |||
listed. The method by which these values should be selected | listed. The method by which these values should be selected | |||
and interpreted is discussed in Section 8.1. | and interpreted is discussed in Section 8.1. | |||
3. If the server chooses to accept the incoming connection, it must | 3. If the server chooses to accept the incoming connection, it MUST | |||
reply with a valid HTTP response indicating the following. | reply with a valid HTTP response indicating the following. | |||
1. A 101 response code. Such a response could look like | 1. A 101 response code. Such a response could look like | |||
"HTTP/1.1 101 Switching Protocols" | "HTTP/1.1 101 Switching Protocols" | |||
2. A "Sec-WebSocket-Accept" header. The value of this header is | 2. A "Sec-WebSocket-Accept" header. The value of this header is | |||
constructed by concatenating /key/, defined above in | constructed by concatenating /key/, defined above in | |||
Paragraph 2 of Section 5.2.2, with the string "258EAFA5-E914- | Paragraph 2 of Section 5.2.2, with the string "258EAFA5-E914- | |||
47DA-95CA-C5AB0DC85B11", taking the SHA-1 hash of this | 47DA-95CA-C5AB0DC85B11", taking the SHA-1 hash of this | |||
concatenated value to obtain a 20-byte value, and base64- | concatenated value to obtain a 20-byte value, and base64- | |||
skipping to change at page 31, line 51 | skipping to change at page 35, line 11 | |||
3. Optionally, a "Sec-WebSocket-Protocol" header, with a value | 3. Optionally, a "Sec-WebSocket-Protocol" header, with a value | |||
/subprotocol/ as defined in Paragraph 2 of Section 5.2.2. | /subprotocol/ as defined in Paragraph 2 of Section 5.2.2. | |||
4. Optionally, a "Sec-WebSocket-Extensions" header, with a value | 4. Optionally, a "Sec-WebSocket-Extensions" header, with a value | |||
/extensions/ as defined in Paragraph 2 of Section 5.2.2. | /extensions/ as defined in Paragraph 2 of Section 5.2.2. | |||
This completes the server's handshake. If the server finishes these | This completes the server's handshake. If the server finishes these | |||
steps without aborting the WebSocket connection, and if the client | steps without aborting the WebSocket connection, and if the client | |||
does not then fail the WebSocket connection, then the connection is | does not then fail the WebSocket connection, then the connection is | |||
established and the server may begin sending and receiving data, as | established and the server may begin sending and receiving data. | |||
described in the next section. | ||||
6. Error Handling | 6. Error Handling | |||
6.1. Handling errors in UTF-8 from the server | 6.1. Handling errors in UTF-8 from the server | |||
When a client is to interpret a byte stream as UTF-8 but finds that | When a client is to interpret a byte stream as UTF-8 but finds that | |||
the byte stream is not in fact a valid UTF-8 stream, then any bytes | the byte stream is not in fact a valid UTF-8 stream, then any bytes | |||
or sequences of bytes that are not valid UTF-8 sequences must be | or sequences of bytes that are not valid UTF-8 sequences MUST be | |||
interpreted as a U+FFFD REPLACEMENT CHARACTER. | interpreted as a U+FFFD REPLACEMENT CHARACTER. | |||
6.2. Handling errors in UTF-8 from the client | 6.2. Handling errors in UTF-8 from the client | |||
When a server is to interpret a byte stream as UTF-8 but finds that | When a server is to interpret a byte stream as UTF-8 but finds that | |||
the byte stream is not in fact a valid UTF-8 stream, behavior is | the byte stream is not in fact a valid UTF-8 stream, behavior is | |||
undefined. A server could close the connection, convert invalid byte | undefined. A server could close the connection, convert invalid byte | |||
sequences to U+FFFD REPLACEMENT CHARACTERs, store the data verbatim, | sequences to U+FFFD REPLACEMENT CHARACTERs, store the data verbatim, | |||
or perform application-specific processing. Subprotocols layered on | or perform application-specific processing. Subprotocols layered on | |||
the WebSocket protocol might define specific behavior for servers. | the WebSocket protocol might define specific behavior for servers. | |||
7. Closing the connection | 7. Closing the connection | |||
7.1. Definitions | 7.1. Definitions | |||
7.1.1. Close the WebSocket Connection | 7.1.1. Close the WebSocket Connection | |||
To _Close the WebSocket Connection_, an endpoint closes the | To _Close the WebSocket Connection_, an endpoint closes the | |||
underlying TCP connection. An endpoint SHOULD use a method that | underlying TCP connection. An endpoint SHOULD use a method that | |||
cleanly closes the TCP connection, discarding any trailing bytes that | cleanly closes the TCP connection, as well as the TLS session, if | |||
may be received. And endpoint MAY close the connection via any means | applicable, discarding any trailing bytes that may be received. An | |||
available when necessary, such as when under attack. | endpoint MAY close the connection via any means available when | |||
necessary, such as when under attack. | ||||
As an example of how to obtain a clean closure in C using Berkeley | As an example of how to obtain a clean closure in C using Berkeley | |||
sockets, one would call shutdown() with SHUT_WR on the socket, call | sockets, one would call shutdown() with SHUT_WR on the socket, call | |||
recv() until obtaining a return value of 0 indicating that the peer | recv() until obtaining a return value of 0 indicating that the peer | |||
has also performed an orderly shutdown, and finally calling close() | has also performed an orderly shutdown, and finally calling close() | |||
on the socket. | on the socket. | |||
7.1.2. Start the WebSocket Closing Handshake | 7.1.2. Start the WebSocket Closing Handshake | |||
To _start the WebSocket closing handshake_, and endpoint MUST send a | To _start the WebSocket closing handshake_, an endpoint MUST send a | |||
Close control frame, as described in Section 4.5.1. Upon receiving a | Close control frame, as described in Section 4.5.1. Once an endpoint | |||
Close control frame, the other party sends a Close control frame in | has both sent and received a Close control frame, that endpoint | |||
response. Once an endpoint has both sent and received a Close | SHOULD _Close the WebSocket Connection_ as defined in Section 7.1.1. | |||
control frame, that endpoint should _Close the WebSocket Connection_ | ||||
as defined in Section 7.1.1. | ||||
7.1.3. The WebSocket Connection Is Closed | 7.1.3. The WebSocket Connection Is Closed | |||
When the underlying TCP connection is closed, it is said that _the | When the underlying TCP connection is closed, it is said that _the | |||
WebSocket connection is closed_. If the tcp connection was closed | WebSocket connection is closed_. If the tcp connection was closed | |||
after the WebSocket closing handshake was completed, the WebSocket | after the WebSocket closing handshake was completed, the WebSocket | |||
connection is said to have been closed _cleanly_. | connection is said to have been closed _cleanly_. | |||
7.1.4. Fail the WebSocket Connection | 7.1.4. Fail the WebSocket Connection | |||
Certain algorithms and specifications require a user agent to _fail | Certain algorithms and specifications require a user agent to _fail | |||
the WebSocket connection_. To do so, the user agent must _Close the | the WebSocket connection_. To do so, the user agent MUST _Close the | |||
WebSocket Connection_, and MAY report the problem to the user (which | WebSocket Connection_, and MAY report the problem to the user (which | |||
would be especially useful for developers) in an appropriate manner. | would be especially useful for developers) in an appropriate manner. | |||
Except as indicated above or as specified by the application layer | Except as indicated above or as specified by the application layer | |||
(e.g. a script using the WebSocket API), user agents SHOULD NOT close | (e.g. a script using the WebSocket API), user agents SHOULD NOT close | |||
the connection. | the connection. | |||
7.2. Abnormal closures | 7.2. Abnormal closures | |||
7.2.1. Client-initiated closure | 7.2.1. Client-initiated closure | |||
Certain algorithms, namely during the initial handshake, require the | Certain algorithms, namely during the initial handshake, require the | |||
user agent to *fail the WebSocket connection*. To do so, the user | user agent to *fail the WebSocket connection*. To do so, the user | |||
agent must _Close the WebSocket connection_ as previously defined, | agent MUST _Close the WebSocket connection_ as previously defined, | |||
and may report the problem to the user via an appropriate mechanism | and MAY report the problem to the user via an appropriate mechanism | |||
(which would be especially useful for developers). | (which would be especially useful for developers). | |||
Except as indicated above or as specified by the application layer | Except as indicated above or as specified by the application layer | |||
(e.g. a script using the WebSocket API), user agents should not close | (e.g. a script using the WebSocket API), user agents SHOULD NOT close | |||
the connection. | the connection. | |||
7.2.2. Server-initiated closure | 7.2.2. Server-initiated closure | |||
Certain algorithms require or recommend that the server _abort the | Certain algorithms require or recommend that the server _abort the | |||
WebSocket connection_ during the opening handshake. To do so, the | WebSocket connection_ during the opening handshake. To do so, the | |||
server must simply _close the WebSocket connection_ (Section 7.1.1). | server MUST simply _close the WebSocket connection_ (Section 7.1.1). | |||
7.3. Normal closure of connections | 7.3. Normal closure of connections | |||
Servers MAY close the WebSocket connection whenever desired. User | Servers MAY close the WebSocket connection whenever desired. User | |||
agents SHOULD NOT close the WebSocket connection arbitrarily. In | agents SHOULD NOT close the WebSocket connection arbitrarily. In | |||
either case, an endpoint initiates a closure by following the | either case, an endpoint initiates a closure by following the | |||
procedures to _start the WebSocket closing handshake_ | procedures to _start the WebSocket closing handshake_ | |||
(Section 7.1.2). | (Section 7.1.2). | |||
7.4. Status codes | 7.4. Status codes | |||
skipping to change at page 35, line 24 | skipping to change at page 39, line 19 | |||
1002 | 1002 | |||
1002 indicates that an endpoint is terminating the connection due | 1002 indicates that an endpoint is terminating the connection due | |||
to a protocol error. | to a protocol error. | |||
1003 | 1003 | |||
1003 indicates that an endpoint is terminating the connection | 1003 indicates that an endpoint is terminating the connection | |||
because it has received a type of data it cannot accept (e.g. an | because it has received a type of data it cannot accept (e.g. an | |||
endpoint that understands only text data may send this if it | endpoint that understands only text data MAY send this if it | |||
receives a binary message.) | receives a binary message). | |||
1004 | 1004 | |||
1004 indicates that an endpoint is terminating the connection | 1004 indicates that an endpoint is terminating the connection | |||
because it has received a message that is too large. | because it has received a message that is too large. | |||
7.4.2. Reserved status code ranges | 7.4.2. Reserved status code ranges | |||
0-999 | 0-999 | |||
skipping to change at page 36, line 9 | skipping to change at page 40, line 8 | |||
3000-3999 | 3000-3999 | |||
Status codes in the range 3000-3999 MAY be used by libraries and | Status codes in the range 3000-3999 MAY be used by libraries and | |||
frameworks. The interpretation of these codes is undefined by | frameworks. The interpretation of these codes is undefined by | |||
this protocol. End applications MUST NOT use status codes in this | this protocol. End applications MUST NOT use status codes in this | |||
range. | range. | |||
4000-4999 | 4000-4999 | |||
Status codes in the range 4000-4999 MAY be used by application | Status codes in the range 4000-4999 MAY be used by application | |||
code. The interpretaion of these codes is undefined by this | code. The interpretation of these codes is undefined by this | |||
protocol. | protocol. | |||
8. Extensions | 8. Extensions | |||
WebSocket clients MAY request extensions to this specification, and | WebSocket clients MAY request extensions to this specification, and | |||
WebSocket servers MAY accept some or all extensions requested by the | WebSocket servers MAY accept some or all extensions requested by the | |||
client. A server MUST NOT respond with any extension not requested | client. A server MUST NOT respond with any extension not requested | |||
by the client. If extension parameters are included in negotiations | by the client. If extension parameters are included in negotiations | |||
between the client and the server, those parameters MUST be chosen in | between the client and the server, those parameters MUST be chosen in | |||
accordance with the specification of the extension to which the | accordance with the specification of the extension to which the | |||
parameters apply. | parameters apply. | |||
8.1. Negotiating extensions | 8.1. Negotiating extensions | |||
A client requests extensions by including a "Sec-WebSocket- | A client requests extensions by including a "Sec-WebSocket- | |||
Extensions" header, which follows the normal rules for HTTP headers | Extensions" header, which follows the normal rules for HTTP headers | |||
(see [RFC2616] section 4.2) and the value of the header is defined by | (see [RFC2616] section 4.2) and the value of the header is defined by | |||
the following ABNF: | the following ABNF. Note that unlike other section of the document | |||
this section is using ABNF syntax/rules from [RFC2616]. | ||||
extension-list = 1#extension | extension-list = 1#extension | |||
extension = extension-token *( ";" extension-param ) | extension = extension-token *( ";" extension-param ) | |||
extension-token = registered-token | private-use-token | extension-token = registered-token | private-use-token | |||
registered-token = token | registered-token = token | |||
private-use-token = "x-" token | private-use-token = "x-" token | |||
extension-param = token [ "=" ( token | quoted-string ) ] | extension-param = token [ "=" ( token | quoted-string ) ] | |||
Note that like other HTTP headers, this header may be split or | Note that like other HTTP headers, this header MAY be split or | |||
combined across multiple lines. Ergo, the following are equivalent: | combined across multiple lines. Ergo, the following are equivalent: | |||
Sec-WebSocket-Extensions: foo | Sec-WebSocket-Extensions: foo | |||
Sec-WebSocket-Extensions: bar; baz=2 | Sec-WebSocket-Extensions: bar; baz=2 | |||
is exactly equivalent to | is exactly equivalent to | |||
Sec-WebSocket-Extensions: foo, bar; baz=2 | Sec-WebSocket-Extensions: foo, bar; baz=2 | |||
Any extension-token used must either be a registered token | Any extension-token used MUST either be a registered token | |||
(registration TBD), or have a prefix of "x-" to indicate a private- | (registration TBD), or have a prefix of "x-" to indicate a private- | |||
use token. The parameters supplied with any given extension MUST be | use token. The parameters supplied with any given extension MUST be | |||
defined for that extension. Note that the client is only offering to | defined for that extension. Note that the client is only offering to | |||
use any advertised extensions, and MUST NOT use them unless the | use any advertised extensions, and MUST NOT use them unless the | |||
server accepts the extension. | server indicates that it wishes to use the extension. | |||
Note that the order of extensions is significant. Any interactions | Note that the order of extensions is significant. Any interactions | |||
between multiple extensions MAY be defined in the documents defining | between multiple extensions MAY be defined in the documents defining | |||
the extensions. In the absence of such definition, the | the extensions. In the absence of such definition, the | |||
interpretation is that the headers listed by the client in its | interpretation is that the headers listed by the client in its | |||
request represent a preference of the headers it wishes to use, with | request represent a preference of the headers it wishes to use, with | |||
the first options listed being most preferable. The extensions | the first options listed being most preferable. The extensions | |||
listed by the server in response represent the extensions actually in | listed by the server in response represent the extensions actually in | |||
use. Should the extensions modify the data and/or framing, the order | use for the connection. Should the extensions modify the data and/or | |||
of operations on the data should be assumed to be the same as the | framing, the order of operations on the data should be assumed to be | |||
order in which the extensions are listed in the server's response in | the same as the order in which the extensions are listed in the | |||
the opening handshake. | server's response in the opening handshake. | |||
For example, if there are two extensions "foo" and "bar", if the | For example, if there are two extensions "foo" and "bar", if the | |||
header |Sec-WebSocket-Extensions| sent by the server has the value | header |Sec-WebSocket-Extensions| sent by the server has the value | |||
"foo, bar" then operations on the data will be made as | "foo, bar" then operations on the data will be made as | |||
bar(foo(data)), be those changes to the data itself (such as | bar(foo(data)), be those changes to the data itself (such as | |||
compression) or changes to the framing thay may "stack". | compression) or changes to the framing thay may "stack". | |||
Non-normative examples of acceptable extension headers: | Non-normative examples of acceptable extension headers: | |||
Sec-WebSocket-Extensions: deflate-stream | Sec-WebSocket-Extensions: deflate-stream | |||
skipping to change at page 38, line 32 | skipping to change at page 42, line 33 | |||
WebSocket-Extensions| header containing one or more extensions which | WebSocket-Extensions| header containing one or more extensions which | |||
were requested by the client. The interpretation of any extension | were requested by the client. The interpretation of any extension | |||
parameters, and what constitutes a valid response by a server to a | parameters, and what constitutes a valid response by a server to a | |||
requested set of parameters by a client, will be defined by each such | requested set of parameters by a client, will be defined by each such | |||
extension. | extension. | |||
8.2. Known extensions | 8.2. Known extensions | |||
Extensions provide a mechanism for implementations to opt-in to | Extensions provide a mechanism for implementations to opt-in to | |||
additional protocol features. This section defines the meaning of | additional protocol features. This section defines the meaning of | |||
well-known extensions but implementations may use extensions defined | well-known extensions but implementations MAY use extensions defined | |||
separately as well. | separately as well. | |||
8.2.1. Compression | 8.2.1. Compression | |||
The registered extension token for this compression extension is | The registered extension token for this compression extension is | |||
"deflate-stream". | "deflate-stream". | |||
The extension does not have any per message extension data and it | The extension does not have any per message extension data and it | |||
does not define the use of any WebSocket reserved bits or op codes. | does not define the use of any WebSocket reserved bits or op codes. | |||
Senders using this extension MUST apply RFC 1951 encodings to all | Senders using this extension MUST apply RFC 1951 encodings to all | |||
bytes of the data stream following the handshake including both data | bytes of the data stream following the handshake including both data | |||
and control messages. The data stream MAY include multiple blocks of | and control messages. The data stream MAY include multiple blocks of | |||
both compressed and uncompressed types as defined by RFC 1951. | both compressed and uncompressed types as defined by [RFC1951]. | |||
[RFC1951] | ||||
Senders MUST NOT delay the transmission of any portion of a WebSocket | Senders MUST NOT delay the transmission of any portion of a WebSocket | |||
message because the deflate encoding of the message does not end on a | message because the deflate encoding of the message does not end on a | |||
byte boundary. The encodings for adjacent messages MAY appear in the | byte boundary. The encodings for adjacent messages MAY appear in the | |||
same byte if no delay in transmission is occurred by doing so. | same byte if no delay in transmission is occurred by doing so. | |||
Historically there have been some confusion and interoperability | ||||
problems around the specification of compression algorithms. In this | ||||
specification "deflate-stream" requires a [RFC1951] deflate encoding. | ||||
It MUST NOT be wrapped in any of the header formats often associated | ||||
with RFC 1951 such as "zlib" [RFC1950]. This requirement is given | ||||
special attention with this note because of confusion in this area, | ||||
the presence of some popular open source libraries that create both | ||||
formats under a single API call with confusing naming conventions, | ||||
and the fact that the popular HTTP [RFC2616] specification defines | ||||
"deflate" compression differently than this specification. | ||||
9. Security considerations | 9. Security considerations | |||
While this protocol is intended to be used by scripts in Web pages, | While this protocol is intended to be used by scripts in Web pages, | |||
it can also be used directly by hosts. Such hosts are acting on | it can also be used directly by hosts. Such hosts are acting on | |||
their own behalf, and can therefore send fake "Origin" fields, | their own behalf, and can therefore send fake "Origin" fields, | |||
misleading the server. Servers should therefore be careful about | misleading the server. Servers should therefore be careful about | |||
assuming that they are talking directly to scripts from known | assuming that they are talking directly to scripts from known | |||
origins, and must consider that they might be accessed in unexpected | origins, and must consider that they might be accessed in unexpected | |||
ways. In particular, a server should not trust that any input is | ways. In particular, a server should not trust that any input is | |||
valid. | valid. | |||
EXAMPLE: For example, if the server uses input as part of SQL | EXAMPLE: For example, if the server uses input as part of SQL | |||
queries, all input text should be escaped before being passed to the | queries, all input text should be escaped before being passed to the | |||
SQL server, lest the server be susceptible to SQL injection. | SQL server, lest the server be susceptible to SQL injection. | |||
Servers that are not intended to process input from any Web page but | Servers that are not intended to process input from any Web page but | |||
only for certain sites should verify the "Origin" field is an origin | only for certain sites SHOULD verify the "Origin" field is an origin | |||
they expect, and should only respond with the corresponding "Sec- | they expect, and should only respond with the corresponding "Sec- | |||
WebSocket-Origin" if it is an accepted origin. Servers that only | WebSocket-Origin" if it is an accepted origin. Servers that only | |||
accept input from one origin can just send back that value in the | accept input from one origin can just send back that value in the | |||
"Sec-WebSocket-Origin" field, without bothering to check the client's | "Sec-WebSocket-Origin" field, without bothering to check the client's | |||
value. | value. | |||
If at any time a server is faced with data that it does not | If at any time a server is faced with data that it does not | |||
understand, or that violates some criteria by which the server | understand, or that violates some criteria by which the server | |||
determines safety of input, or when the server sees a handshake that | determines safety of input, or when the server sees a handshake that | |||
does not correspond to the values the server is expecting (e.g. | does not correspond to the values the server is expecting (e.g. | |||
incorrect path or origin), the server should just disconnect. It is | incorrect path or origin), the server SHOULD just disconnect. It is | |||
always safe to disconnect. | always safe to disconnect. | |||
The biggest security risk when sending text data using this protocol | The biggest security risk when sending text data using this protocol | |||
is sending data using the wrong encoding. If an attacker can trick | is sending data using the wrong encoding. If an attacker can trick | |||
the server into sending data encoded as ISO-8859-1 verbatim (for | the server into sending data encoded as ISO-8859-1 verbatim (for | |||
instance), rather than encoded as UTF-8, then the attacker could | instance), rather than encoded as UTF-8, then the attacker could | |||
inject arbitrary frames into the data stream. | inject arbitrary frames into the data stream. | |||
In addition to endpoints being the target of attacks via WebSockets, | In addition to endpoints being the target of attacks via WebSockets, | |||
other parts of web infrastructure, such as proxies, may be the | other parts of web infrastructure, such as proxies, may be the | |||
skipping to change at page 42, line 5 | skipping to change at page 45, line 12 | |||
browser to send a message that looks to an intermediary like a GET | browser to send a message that looks to an intermediary like a GET | |||
request for a common piece of JavaScript on another domain, and send | request for a common piece of JavaScript on another domain, and send | |||
back a message that is interpreted as a cacheable response to that | back a message that is interpreted as a cacheable response to that | |||
request, thus poisioning the cache for other users. To prevent this | request, thus poisioning the cache for other users. To prevent this | |||
attack, messages sent from clients are masked on the wire with a 32- | attack, messages sent from clients are masked on the wire with a 32- | |||
bit value, to prevent an attacker from controlling the bits on the | bit value, to prevent an attacker from controlling the bits on the | |||
wire and thus lessen the probability of an attacker being able to | wire and thus lessen the probability of an attacker being able to | |||
construct a message that can be misinterpreted by a proxy as a non- | construct a message that can be misinterpreted by a proxy as a non- | |||
WebSocket request. | WebSocket request. | |||
As mentioned in Section 6.2, servers must be extremely cautious | ||||
interpreting invalid UTF-8 data from the client. A naive UTF-8 | ||||
parsing implementation can result in buffer overflows in the case of | ||||
invalid input data. | ||||
10. IANA considerations | 10. IANA considerations | |||
10.1. Registration of ws: scheme | 10.1. Registration of ws: scheme | |||
A |ws:| URI identifies a WebSocket server and resource name. | A |ws:| URI identifies a WebSocket server and resource name. | |||
URI scheme name. | URI scheme name. | |||
ws | ws | |||
Status. | Status. | |||
Permanent. | Permanent. | |||
URI scheme syntax. | URI scheme syntax. | |||
In ABNF terms using the terminals from the URI specifications: | In ABNF terms using the terminals from the URI specifications: | |||
[RFC5234] [RFC3986] | [RFC5234] [RFC3986] | |||
"ws" ":" hier-part [ "?" query ] | "ws" ":" hier-part [ "?" query ] | |||
The path and query components form the resource name sent to the | The <path> [RFC3986] and <query> components form the resource name | |||
server to identify the kind of service desired. Other components | sent to the server to identify the kind of service desired. Other | |||
have the meanings described in RFC3986. | components have the meanings described in RFC3986. | |||
URI scheme semantics. | URI scheme semantics. | |||
The only operation for this scheme is to open a connection using | The only operation for this scheme is to open a connection using | |||
the WebSocket protocol. | the WebSocket protocol. | |||
Encoding considerations. | Encoding considerations. | |||
Characters in the host component that are excluded by the syntax | Characters in the host component that are excluded by the syntax | |||
defined above must be converted from Unicode to ASCII by applying | defined above MUST be converted from Unicode to ASCII by applying | |||
the IDNA ToASCII algorithm to the Unicode host name, with both the | the IDNA ToASCII algorithm to the Unicode host name, with both the | |||
AllowUnassigned and UseSTD3ASCIIRules flags set, and using the | AllowUnassigned and UseSTD3ASCIIRules flags set, and using the | |||
result of this algorithm as the host in the URI. [RFC3490] | result of this algorithm as the host in the URI. [RFC3490] | |||
Characters in other components that are excluded by the syntax | Characters in other components that are excluded by the syntax | |||
defined above must be converted from Unicode to ASCII by first | defined above MUST be converted from Unicode to ASCII by first | |||
encoding the characters as UTF-8 and then replacing the | encoding the characters as UTF-8 and then replacing the | |||
corresponding bytes using their percent-encoded form as defined in | corresponding bytes using their percent-encoded form as defined in | |||
the URI and IRI specification. [RFC3986] [RFC3987] | the URI and IRI specifications. [RFC3986] [RFC3987] | |||
Applications/protocols that use this URI scheme name. | Applications/protocols that use this URI scheme name. | |||
WebSocket protocol. | WebSocket protocol. | |||
Interoperability considerations. | Interoperability considerations. | |||
None. | None. | |||
Security considerations. | Security considerations. | |||
See "Security considerations" section above. | See "Security considerations" section above. | |||
Contact. | Contact. | |||
Ian Hickson <ian@hixie.ch> | HYBI WG <hybi@ietf.org> | |||
Author/Change controller. | Author/Change controller. | |||
Ian Hickson <ian@hixie.ch> | IETF <iesg@ietf.org> | |||
References. | References. | |||
This document. | RFC XXXX | |||
10.2. Registration of wss: scheme | 10.2. Registration of wss: scheme | |||
A |wss:| URI identifies a WebSocket server and resource name, and | A |wss:| URI identifies a WebSocket server and resource name, and | |||
indicates that traffic over that connection is to be encrypted. | indicates that traffic over that connection is to be encrypted. | |||
URI scheme name. | URI scheme name. | |||
wss | wss | |||
Status. | Status. | |||
Permanent. | Permanent. | |||
URI scheme syntax. | URI scheme syntax. | |||
In ABNF terms using the terminals from the URI specifications: | In ABNF terms using the terminals from the URI specifications: | |||
[RFC5234] [RFC3986] | [RFC5234] [RFC3986] | |||
"wss" ":" hier-part [ "?" query ] | "wss" ":" hier-part [ "?" query ] | |||
The path and query components form the resource name sent to the | The <path> and <query> components form the resource name sent to | |||
server to identify the kind of service desired. Other components | the server to identify the kind of service desired. Other | |||
have the meanings described in RFC3986. | components have the meanings described in RFC3986. | |||
URI scheme semantics. | URI scheme semantics. | |||
The only operation for this scheme is to open a connection using | The only operation for this scheme is to open a connection using | |||
the WebSocket protocol, encrypted using TLS. | the WebSocket protocol, encrypted using TLS. | |||
Encoding considerations. | Encoding considerations. | |||
Characters in the host component that are excluded by the syntax | Characters in the host component that are excluded by the syntax | |||
defined above must be converted from Unicode to ASCII by applying | defined above MUST be converted from Unicode to ASCII by applying | |||
the IDNA ToASCII algorithm to the Unicode host name, with both the | the IDNA ToASCII algorithm to the Unicode host name, with both the | |||
AllowUnassigned and UseSTD3ASCIIRules flags set, and using the | AllowUnassigned and UseSTD3ASCIIRules flags set, and using the | |||
result of this algorithm as the host in the URI. [RFC3490] | result of this algorithm as the host in the URI. [RFC3490] | |||
Characters in other components that are excluded by the syntax | Characters in other components that are excluded by the syntax | |||
defined above must be converted from Unicode to ASCII by first | defined above MUST be converted from Unicode to ASCII by first | |||
encoding the characters as UTF-8 and then replacing the | encoding the characters as UTF-8 and then replacing the | |||
corresponding bytes using their percent-encoded form as defined in | corresponding bytes using their percent-encoded form as defined in | |||
the URI and IRI specification. [RFC3986] [RFC3987] | the URI and IRI specification. [RFC3986] [RFC3987] | |||
Applications/protocols that use this URI scheme name. | Applications/protocols that use this URI scheme name. | |||
WebSocket protocol over TLS. | WebSocket protocol over TLS. | |||
Interoperability considerations. | Interoperability considerations. | |||
None. | None. | |||
Security considerations. | Security considerations. | |||
See "Security considerations" section above. | See "Security considerations" section above. | |||
Contact. | Contact. | |||
Ian Hickson <ian@hixie.ch> | HYBI WG <hybi@ietf.org> | |||
Author/Change controller. | Author/Change controller. | |||
Ian Hickson <ian@hixie.ch> | IETF <iesg@ietf.org> | |||
References. | References. | |||
This document. | RFC XXXX | |||
10.3. Registration of the "WebSocket" HTTP Upgrade keyword | 10.3. Registration of the "WebSocket" HTTP Upgrade keyword | |||
Name of token. | Name of token. | |||
WebSocket | WebSocket | |||
Author/Change controller. | Author/Change controller. | |||
Ian Hickson <ian@hixie.ch> | IETF <iesg@ietf.org> | |||
Contact. | Contact. | |||
Ian Hickson <ian@hixie.ch> | HYBI <hybi@ietf.org> | |||
References. | References. | |||
This document. | RFC XXXX | |||
10.4. Sec-WebSocket-Key | 10.4. Sec-WebSocket-Key | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Key | Sec-WebSocket-Key | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Key| header is used in the WebSocket handshake. | The |Sec-WebSocket-Key| header is used in the WebSocket handshake. | |||
It is sent from the client to the server to provide part of the | It is sent from the client to the server to provide part of the | |||
information used by the server to prove that it received a valid | information used by the server to prove that it received a valid | |||
WebSocket handshake. This helps ensure that the server does not | WebSocket handshake. This helps ensure that the server does not | |||
accept connections from non-WebSocket clients (e.g. HTTP clients) | accept connections from non-WebSocket clients (e.g. HTTP clients) | |||
that are being abused to send data to unsuspecting WebSocket servers. | that are being abused to send data to unsuspecting WebSocket servers. | |||
10.5. Sec-WebSocket-Extensions | 10.5. Sec-WebSocket-Extensions | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Extensions | Sec-WebSocket-Extensions | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Extensions| header is used in the WebSocket | The |Sec-WebSocket-Extensions| header is used in the WebSocket | |||
handshake. It is initially sent from the client to the server, and | handshake. It is initially sent from the client to the server, and | |||
then subsequently sent from the servver to the client, to agree on a | then subsequently sent from the server to the client, to agree on a | |||
set of protocol-level extensions to use during the connection. | set of protocol-level extensions to use for the duration of the | |||
connection. | ||||
10.6. Sec-WebSocket-Accept | 10.6. Sec-WebSocket-Accept | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Accept | Sec-WebSocket-Accept | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Accept| header is used in the WebSocket handshake. | The |Sec-WebSocket-Accept| header is used in the WebSocket handshake. | |||
It is sent from the server to the client to confirm that the server | It is sent from the server to the client to confirm that the server | |||
is willing to initiate the connection. | is willing to initiate the connection. | |||
10.7. Sec-WebSocket-Origin | 10.7. Sec-WebSocket-Origin | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Origin | Sec-WebSocket-Origin | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Origin| header is used in the WebSocket handshake. | The |Sec-WebSocket-Origin| header is used in the WebSocket handshake. | |||
It is sent from the server to the client to confirm the origin of the | It is sent from the server to the client to confirm the origin of the | |||
script that opened the connection. This enables user agents to | script that opened the connection. This enables user agents to | |||
verify that the server is willing to serve the script that opened the | verify that the server is willing to serve the script that opened the | |||
connection. | connection. | |||
10.8. Sec-WebSocket-Protocol | 10.8. Sec-WebSocket-Protocol | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Protocol | Sec-WebSocket-Protocol | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Protocol| header is used in the WebSocket | The |Sec-WebSocket-Protocol| header is used in the WebSocket | |||
handshake. It is sent from the client to the server and back from | handshake. It is sent from the client to the server and back from | |||
the server to the client to confirm the subprotocol of the | the server to the client to confirm the subprotocol of the | |||
connection. This enables scripts to both select a subprotocol and be | connection. This enables scripts to both select a subprotocol and be | |||
sure that the server agreed to serve that subprotocol. | sure that the server agreed to serve that subprotocol. | |||
10.9. Sec-WebSocket-Version | 10.9. Sec-WebSocket-Version | |||
This section describes a header field for registration in the | This section describes a header field for registration in the | |||
Permanent Message Header Field Registry. [RFC3864] | Permanent Message Header Field Registry. [RFC3864] | |||
Header field name | Header field name | |||
Sec-WebSocket-Version | Sec-WebSocket-Version | |||
Applicable protocol | Applicable protocol | |||
http | http | |||
Status | Status | |||
reserved; do not use outside WebSocket handshake | standard | |||
Author/Change controller | Author/Change controller | |||
IETF | IETF | |||
Specification document(s) | Specification document(s) | |||
This document is the relevant specification. | RFC XXXX | |||
Related information | Related information | |||
None. | This header field is only used for WebSocket handshake. | |||
The |Sec-WebSocket-Version| header is used in the WebSocket | The |Sec-WebSocket-Version| header is used in the WebSocket | |||
handshake. It is sent from the client to the server to indicate the | handshake. It is sent from the client to the server to indicate the | |||
protocol version of the connection. This enables servers to | protocol version of the connection. This enables servers to | |||
correctly interpret the handshake and subsequent data being sent from | correctly interpret the handshake and subsequent data being sent from | |||
the data, and close the connection if the server cannot interpret | the data, and close the connection if the server cannot interpret | |||
that data in a safe manner. | that data in a safe manner. | |||
11. Using the WebSocket protocol from other specifications | 11. Using the WebSocket protocol from other specifications | |||
skipping to change at page 51, line 5 | skipping to change at page 55, line 5 | |||
specification is given in the WHATWG HTML specification at | specification is given in the WHATWG HTML specification at | |||
http://whatwg.org/html5. | http://whatwg.org/html5. | |||
Special thanks also to John Tamplin for providing a significant | Special thanks also to John Tamplin for providing a significant | |||
amount of text for the Data Framing section of this specification. | amount of text for the Data Framing section of this specification. | |||
Special thanks also to Adam Barth for providing a significant amount | Special thanks also to Adam Barth for providing a significant amount | |||
of text and background research for the Data Masking section of this | of text and background research for the Data Masking section of this | |||
specification. | specification. | |||
13. Appendix: List of Changes | 13. References | |||
This section is not normative. This section was added at the request | ||||
of the chairs to help track changes between versions. This section | ||||
will be removed from the final version of this document. | ||||
13.1. Changes from -05 to -06 | ||||
Two major areas were changed in this draft. The closing handshake | ||||
was clarified and re-written to add in terminology matching the API | ||||
specification. The close frame was given an optional status code to | ||||
indicate closure reason, and the notion of a body indicating which | ||||
side initiated the close removed. Aside from this, many areas were | ||||
clarified in areas previously ambiguous, though the meaning should | ||||
remain consistent with the intent of previous drafts. Certain other | ||||
material changes that are not as large as those previously mentioned | ||||
are listed below, though for a complete list readers are reminded | ||||
that a tool is available to diff two versions at | ||||
http://tools.ietf.org/tools/rfcdiff/. The list below is my attempt | ||||
at a changelog, not an authoritative guarantee, plese use the diff | ||||
tool for a complete list. | ||||
o Clarified that Sec-WebSocket-Origin is optional for non-browser | ||||
clients. | ||||
o Clarified the semantics of the closing handshake to be that the | ||||
connection is closed when an endpoint has both sent and received a | ||||
close frame. | ||||
o Changed text around final HTTP responses and the WebSocket | ||||
handshake. | ||||
o Removed Sec-WebSocket-Nonce | ||||
o Attempted to convert use of URL to URI terminology. (Ticket 41) | ||||
o Attempted to resolve Ticket 42 re: HTML spec reference. | ||||
o Edited potentially misleadin text around the word "even" in | ||||
Section 1.6 and what applied to XHR vs more broadly. | ||||
o Removed non-material text from 1.8 about establishing a | ||||
connection. | ||||
o Clarified text in the section about fragmentation (4.4). No | ||||
material changes, clarification only. | ||||
o Clarified that control frames (4.5) may be interjected in the | ||||
middle of a fragmented message. | ||||
o Clarified what was meant by the body of a close frame. | ||||
o Clarified the intent in 5.1 that there be only one connection in | ||||
CONNECTING state. | ||||
o Cleaned 1.5 up to note that compression was already introduced in | ||||
the spec, left in multiplexing as a future definition. | ||||
o Randomly selected randomly - typo fix. | ||||
o Added a change log in the appendix. | ||||
o Included in security considerations a description of the attack | ||||
presented by Adam Barth. | ||||
o Changed some referneces from Web-Socket to WebSocket | ||||
o Clarified in 3.1 that only ws and wss are valid options, and that | ||||
other schemes should result in a failure. | ||||
o Various cleanups around terminology of "host", "endpoint", and | ||||
"user agent". | ||||
o Defined status codes and reserved ranges for close frames. | ||||
o Added text that a TCP connection should be shut down cleanly. | ||||
o Clarified whether the upgrade header exactly equaled upgrade or | ||||
contained an upgrade token. | ||||
14. Normative References | 13.1. Normative References | |||
[ANSI.X3-4.1986] | [ANSI.X3-4.1986] | |||
American National Standards Institute, "Coded Character | American National Standards Institute, "Coded Character | |||
Set - 7-bit American Standard Code for Information | Set - 7-bit American Standard Code for Information | |||
Interchange", ANSI X3.4, 1986. | Interchange", ANSI X3.4, 1986. | |||
[FIPS.180-2.2002] | [FIPS.180-2.2002] | |||
National Institute of Standards and Technology, "Secure | National Institute of Standards and Technology, "Secure | |||
Hash Standard", FIPS PUB 180-2, August 2002, <http:// | Hash Standard", FIPS PUB 180-2, August 2002, <http:// | |||
csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf>. | csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf>. | |||
[RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification | [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification | |||
version 1.3", RFC 1951, May 1996. | version 1.3", RFC 1951, May 1996. | |||
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
Requirement Levels", BCP 14, RFC 2119, March 1997. | Requirement Levels", BCP 14, RFC 2119, March 1997. | |||
[RFC2246] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", | ||||
RFC 2246, January 1999. | ||||
[RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., | [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., | |||
Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext | Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext | |||
Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. | Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. | |||
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. | ||||
[RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, | [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, | |||
"Internationalizing Domain Names in Applications (IDNA)", | "Internationalizing Domain Names in Applications (IDNA)", | |||
RFC 3490, March 2003. | RFC 3490, March 2003. | |||
[RFC3492] Costello, A., "Punycode: A Bootstring encoding of Unicode | ||||
for Internationalized Domain Names in Applications | ||||
(IDNA)", RFC 3492, March 2003. | ||||
[RFC3548] Josefsson, S., "The Base16, Base32, and Base64 Data | [RFC3548] Josefsson, S., "The Base16, Base32, and Base64 Data | |||
Encodings", RFC 3548, July 2003. | Encodings", RFC 3548, July 2003. | |||
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO | [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO | |||
10646", STD 63, RFC 3629, November 2003. | 10646", STD 63, RFC 3629, November 2003. | |||
[RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration | [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration | |||
Procedures for Message Header Fields", BCP 90, RFC 3864, | Procedures for Message Header Fields", BCP 90, RFC 3864, | |||
September 2004. | September 2004. | |||
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform | [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform | |||
Resource Identifier (URI): Generic Syntax", STD 66, | Resource Identifier (URI): Generic Syntax", STD 66, | |||
RFC 3986, January 2005. | RFC 3986, January 2005. | |||
[RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource | [RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource | |||
Identifiers (IRIs)", RFC 3987, January 2005. | Identifiers (IRIs)", RFC 3987, January 2005. | |||
[RFC4366] Blake-Wilson, S., Nystrom, M., Hopwood, D., Mikkelsen, J., | [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security | |||
and T. Wright, "Transport Layer Security (TLS) | (TLS) Protocol Version 1.2", RFC 5246, August 2008. | |||
Extensions", RFC 4366, April 2006. | ||||
[RFC6066] Eastlake, D., "Transport Layer Security (TLS) Extensions: | ||||
Extension Definitions", RFC 6066, January 2011. | ||||
[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data | ||||
Encodings", RFC 4648, October 2006. | ||||
[RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax | [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax | |||
Specifications: ABNF", STD 68, RFC 5234, January 2008. | Specifications: ABNF", STD 68, RFC 5234, January 2008. | |||
13.2. Informative References | ||||
[WSAPI] Hickson, I., "The Web Sockets API", August 2010, | ||||
<http://dev.w3.org/html5/websockets/>. | ||||
[I-D.ietf-httpstate-cookie] | [I-D.ietf-httpstate-cookie] | |||
Barth, A., "HTTP State Management Mechanism", | Barth, A., "HTTP State Management Mechanism", | |||
draft-ietf-httpstate-cookie-20 (work in progress), | draft-ietf-httpstate-cookie-20 (work in progress), | |||
December 2010. | December 2010. | |||
[I-D.ietf-websec-origin] | [I-D.ietf-websec-origin] | |||
Barth, A., "The Web Origin Concept", | Barth, A., "The Web Origin Concept", | |||
draft-ietf-websec-origin-00 (work in progress), | draft-ietf-websec-origin-00 (work in progress), | |||
December 2010. | December 2010. | |||
[WSAPI] Hickson, I., "The Web Sockets API", August 2010, | [RFC1950] Deutsch, L. and J-L. Gailly, "ZLIB Compressed Data Format | |||
<http://dev.w3.org/html5/websockets/>. | Specification version 3.3", RFC 1950, May 1996. | |||
[RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, | ||||
October 2008. | ||||
[RFC6202] Loreto, S., Saint-Andre, P., Salsano, S., and G. Wilkins, | ||||
"Known Issues and Best Practices for the Use of Long | ||||
Polling and Streaming in Bidirectional HTTP", RFC 6202, | ||||
April 2011. | ||||
Author's Address | Author's Address | |||
Ian Fette | Ian Fette | |||
Google, Inc. | Google, Inc. | |||
Email: ifette+ietf@google.com | Email: ifette+ietf@google.com | |||
URI: http://www.ianfette.com/ | URI: http://www.ianfette.com/ | |||
End of changes. 172 change blocks. | ||||
483 lines changed or deleted | 544 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |