draft-ietf-hybi-thewebsocketprotocol-02.txt   draft-ietf-hybi-thewebsocketprotocol-03.txt 
HyBi Working Group I. Fette HyBi Working Group I. Fette
Internet-Draft Google, Inc. Internet-Draft Google, Inc.
Intended status: Standards Track September 24, 2010 Intended status: Standards Track October 17, 2010
Expires: March 28, 2011 Expires: April 20, 2011
The WebSocket protocol The WebSocket protocol
draft-ietf-hybi-thewebsocketprotocol-02 draft-ietf-hybi-thewebsocketprotocol-03
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 2, line 30 skipping to change at page 2, line 30
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 March 28, 2011. This Internet-Draft will expire on April 20, 2011.
Copyright Notice Copyright Notice
Copyright (c) 2010 IETF Trust and the persons identified as the Copyright (c) 2010 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 3, line 10 skipping to change at page 3, line 10
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 5 1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 5
1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 9 1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 8
1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 12 1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 11
1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 13 1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 12
1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 14 1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 12
1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 14 1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 13
1.8. Establishing a connection . . . . . . . . . . . . . . . . 14 1.8. Establishing a connection . . . . . . . . . . . . . . . . 13
1.9. Subprotocols using the WebSocket protocol . . . . . . . . 15 1.9. Subprotocols using the WebSocket protocol . . . . . . . . 14
2. Conformance requirements . . . . . . . . . . . . . . . . . . . 17 2. Conformance requirements . . . . . . . . . . . . . . . . . . . 15
2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 17 2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 15
3. WebSocket URLs . . . . . . . . . . . . . . . . . . . . . . . . 19 3. WebSocket URLs . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1. Parsing WebSocket URLs . . . . . . . . . . . . . . . . . . 19 3.1. Parsing WebSocket URLs . . . . . . . . . . . . . . . . . . 17
3.2. Constructing WebSocket URLs . . . . . . . . . . . . . . . 20 3.2. Constructing WebSocket URLs . . . . . . . . . . . . . . . 18
3.3. Valid WebSocket URLs . . . . . . . . . . . . . . . . . . . 20 3.3. Valid WebSocket URLs . . . . . . . . . . . . . . . . . . . 18
4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 22 4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2. Base Framing Protocol . . . . . . . . . . . . . . . . . . 22 4.2. Base Framing Protocol . . . . . . . . . . . . . . . . . . 20
4.3. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 23 4.3. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 22
4.4. Control Frames . . . . . . . . . . . . . . . . . . . . . . 24 4.4. Control Frames . . . . . . . . . . . . . . . . . . . . . . 23
4.5. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 25 4.4.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 23
4.6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.4.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.7. Extensibility . . . . . . . . . . . . . . . . . . . . . . 26 4.4.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 24
5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 27 4.5. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 24
5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 27 4.6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.2. Server-side requirements . . . . . . . . . . . . . . . . . 37 4.7. Extensibility . . . . . . . . . . . . . . . . . . . . . . 25
5.2.1. Reading the client's opening handshake . . . . . . . . 37 5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 26
5.2.2. Sending the server's opening handshake . . . . . . . . 40 5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 26
6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 45 5.2. Server-side requirements . . . . . . . . . . . . . . . . . 36
6.1. Handling errors in UTF-8 from the server . . . . . . . . . 45 5.2.1. Reading the client's opening handshake . . . . . . . . 36
6.2. Handling errors in UTF-8 from the client . . . . . . . . . 45 5.2.2. Sending the server's opening handshake . . . . . . . . 39
7. Closing the connection . . . . . . . . . . . . . . . . . . . . 46 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 44
7.1. Client-initiated closure . . . . . . . . . . . . . . . . . 46 6.1. Handling errors in UTF-8 from the server . . . . . . . . . 44
7.2. Server-initiated closure . . . . . . . . . . . . . . . . . 46 6.2. Handling errors in UTF-8 from the client . . . . . . . . . 44
7.3. Closure . . . . . . . . . . . . . . . . . . . . . . . . . 46 7. Closing the connection . . . . . . . . . . . . . . . . . . . . 45
8. Security considerations . . . . . . . . . . . . . . . . . . . 48 7.1. Client-initiated closure . . . . . . . . . . . . . . . . . 45
9. IANA considerations . . . . . . . . . . . . . . . . . . . . . 49 7.2. Server-initiated closure . . . . . . . . . . . . . . . . . 45
9.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 49 7.3. Closure . . . . . . . . . . . . . . . . . . . . . . . . . 45
9.2. Registration of wss: scheme . . . . . . . . . . . . . . . 50 8. Known extensions . . . . . . . . . . . . . . . . . . . . . . . 47
9.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 51 8.1. Compression . . . . . . . . . . . . . . . . . . . . . . . 47
9.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2 . . . . . . . . 51 9. Security considerations . . . . . . . . . . . . . . . . . . . 48
9.5. Sec-WebSocket-Location . . . . . . . . . . . . . . . . . . 52 10. IANA considerations . . . . . . . . . . . . . . . . . . . . . 49
9.6. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 53 10.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 49
9.7. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 54 10.2. Registration of wss: scheme . . . . . . . . . . . . . . . 50
9.8. Sec-WebSocket-Draft . . . . . . . . . . . . . . . . . . . 54 10.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 51
10.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2 . . . . . . . . 51
10. Using the WebSocket protocol from other specifications . . . . 56 10.5. Sec-WebSocket-Location . . . . . . . . . . . . . . . . . . 52
11. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 57 10.6. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 53
12. Normative References . . . . . . . . . . . . . . . . . . . . . 58 10.7. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 54
10.8. Sec-WebSocket-Draft . . . . . . . . . . . . . . . . . . . 54
11. Using the WebSocket protocol from other specifications . . . . 56
12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 57
13. Normative References . . . . . . . . . . . . . . . . . . . . . 58
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 60 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 60
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
skipping to change at page 6, line 34 skipping to change at page 6, line 34
8jKS'y:G*Co,Wxa- 8jKS'y:G*Co,Wxa-
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 the HTTP Request-Line and Status-Line productions are defined in the HTTP
specification. specification.
After the leading line in both cases come an unordered ASCII case- After the leading line in both cases come an unordered ASCII case-
insensitive set of fields, one per line, that each match the insensitive set of fields, one per line, that each match the
following non-normative ABNF: [RFC5234] following non-normative ABNF: [RFC5234] [ANSI.X3-4.1986]
field = 1*name-char colon [ space ] *any-char cr lf field = 1*name-char colon [ space ] *any-char cr lf
colon = %x003A ; U+003A COLON (:) colon = %x003A ; U+003A COLON (:)
space = %x0020 ; U+0020 SPACE space = %x0020 ; U+0020 SPACE
cr = %x000D ; U+000D CARRIAGE RETURN (CR) cr = %x000D ; U+000D CARRIAGE RETURN (CR)
lf = %x000A ; U+000A LINE FEED (LF) lf = %x000A ; U+000A LINE FEED (LF)
name-char = %x0000-0009 name-char = %x0000-0009
/ %x000B-000C / %x000B-000C
/ %x000E-0039 / %x000E-0039
/ %x003B-10FFFF / %x003B-10FFFF
; a Unicode character other than ; a Unicode character other than
skipping to change at page 7, line 45 skipping to change at page 7, line 45
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. On the network layer, a terms of sending and receiving messages. The websocket message does
message may be represented as one or more frames. not necessarily correspond to a particular network layer framing, as
a fragmented message may be coalesced, or vice versa, e.g. by an
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. Broadly speaking, there are types for textual data,
which is interpreted as UTF-8 text, binary data (whose interpretation which is interpreted as UTF-8 text, binary data (whose interpretation
is left up to the application), and control frames, which are not is left up to the application), and control frames, which are not
intended to carry data for the application, but instead for protocol- intended to carry data for the application, but instead for protocol-
level signalling, such as to signal that the connection should be level signalling, such as to signal that the connection should be
closed. 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.
To close the connection cleanly, a control frame is sent from one
peer to ask that the other peer close the connection. Details are
specified in Section 7.
The protocol is designed to support other frame types in future.
Currently only four frame types are defined -- continuation (used for
fragmented messages), control frames, text frames, and binary data
frames. Eight frame types are reserved for future use, and four
frame types are reserved for private use.
This wire format for the data transfer part is described by the ABNF
given in detail in Section 4. A high level overview of the framing
is given in the following figure. [RFC5234]
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
+-+-+-+-+-------+-+-------------+-------------------------------+
|M|R|R|R| opcode|R| Payload len | Extended payload length |
|O|S|S|S| (4) |S| (7) | (16/63) |
|R|V|V|V| |V| | (if payload len==126/127) |
|E|1|2|3| |4| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| | Extension data |
+-------------------------------+ - - - - - - - - - - - - - - - +
: :
+---------------------------------------------------------------+
: Application data :
+---------------------------------------------------------------+
MORE: 1 bit
Indicates more fragments follow in the current message
RSV1, RSV2, RSV3, RSV4: 1 bit each
Must be 0 unless an extension is negotiated which defines meanings
for non-zero values
Opcode: 4 bits
Defines the interpretation of the payload data
Payload length: 7 bits
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
integer are the payload length. If 127, the following 8 bytes
interpreted as a 64-bit unsigned integer (the high bit must be 0)
are the payload length. The payload length is the length of the
Extension data + the length of the Application Data. The length
of the Extension data may be zero, in which case the Payload
length is the length of the Application data.
Extension data: n bytes
Only present if an extension is negotiated during the handshake
which defines it. If present, it is included in the total payload
length.
Application data: n bytes
Arbitrary application data, taking up the remainder of the frame
after any extension data. The length of the Application data is
equal to the payload length minus the length of the Extension
data.
1.3. Opening handshake 1.3. Opening handshake
_This section is non-normative._ _This section is non-normative._
The opening handshake is intended to be compatible with HTTP-based The opening handshake is intended to be compatible with HTTP-based
server-side software, so that a single port can be used by both HTTP server-side software, so that a single port can be used by both HTTP
clients talking to that server and WebSocket clients talking to that clients talking to that server and WebSocket clients talking to that
server. To this end, the WebSocket client's handshake appears to server. To this end, the WebSocket client's handshake appears to
HTTP servers to be a regular GET request with an Upgrade offer: HTTP servers to be a regular GET request with an Upgrade offer:
skipping to change at page 10, line 12 skipping to change at page 8, line 39
Upgrade: WebSocket Upgrade: WebSocket
Connection: Upgrade Connection: Upgrade
Fields in the handshake are sent by the client in a random order; the Fields in the handshake are sent by the client in a random order; the
order is not meaningful. order is not meaningful.
Additional fields are used to select options in the WebSocket Additional fields are used to select options in the WebSocket
protocol. The only options available in this version are the protocol. The only options available in this version are the
subprotocol selector, |Sec-WebSocket-Protocol|, and |Cookie|, which subprotocol selector, |Sec-WebSocket-Protocol|, and |Cookie|, which
can used for sending cookies to the server (e.g. as an authentication can used for sending cookies to the server (e.g. as an authentication
mechanism). The |Sec-WebSocket-Protocol| field takes an arbitrary mechanism). The |Sec-WebSocket-Protocol| request-header field can be
string: used to indicate what subprotocols (application-level protocols
layered over the WebSocket protocol) are acceptable to the client.
Sec-WebSocket-Protocol: chat The server selects one of the acceptable protocols and echoes that
value in its handshake to indicate that it has selected that
protocol.
This field indicates the subprotocol (the application-level protocol Sec-WebSocket-Protocol: chat superchat
layered over the WebSocket protocol) that the client intends to use.
The server echoes this field in its handshake to indicate that it
supports that subprotocol.
The other fields in the handshake are all security-related. The The other fields in the handshake are all security-related. The
|Host| field is used to protect against DNS rebinding attacks and to |Host| field is used to protect against DNS rebinding attacks and to
allow multiple domains to be served from one IP address. allow multiple domains to be served from one IP address.
Host: example.com Host: example.com
The server includes the hostname in the |Sec-WebSocket-Location| The server includes the hostname in the |Sec-WebSocket-Location|
field of its handshake, so that both the client and the server can field of its handshake, so that both the client and the server can
verify that they agree on which host is in use. verify that they agree on which host is in use.
skipping to change at page 12, line 23 skipping to change at page 10, line 47
Sec-WebSocket-Location: ws://example.com/ Sec-WebSocket-Location: ws://example.com/
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. A server that only handles |WebSocket| client for scripted pages. A server that only handles
one origin and only serves one resource can therefore just return one origin and only serves one resource can therefore just return
hard-coded values and does not need to parse the client's handshake hard-coded values and does not need to parse the client's handshake
to verify the correctness of the values. to verify the correctness of the values.
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 speaks. Web browsers verify that the the subprotocol that the server has selected. Web browsers verify
server included the same value as was specified in the |WebSocket| that the server included one of the values as was specified in the
constructor, so a server that speaks multiple subprotocols has to |WebSocket| constructor.A server that speaks multiple subprotocols
make sure it selects one based on the client's handshake and has to make sure it selects one based on the client's handshake and
specifies the right one in its handshake. 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.
After the fields, the server sends the aforementioned MD5 sum, a 16 After the fields, the server sends the aforementioned MD5 sum, a 16
byte (128 bit) value, shown here as if interpreted as UTF-8: byte (128 bit) value, shown here as if interpreted as UTF-8:
fQJ,fN/4F4!~K~MH fQJ,fN/4F4!~K~MH
skipping to change at page 15, line 32 skipping to change at page 14, line 11
setups (e.g. with load balancers and multiple servers), a dedicated setups (e.g. with load balancers and multiple servers), a dedicated
set of hosts for WebSocket connections separate from the HTTP servers set of hosts for WebSocket connections separate from the HTTP servers
is probably easier to manage. is probably easier to manage.
1.9. Subprotocols using the WebSocket protocol 1.9. Subprotocols using the WebSocket protocol
_This section is non-normative._ _This section is non-normative._
The client can request that the server use a specific subprotocol by The client can request that the server use a specific subprotocol by
including the |Sec-Websocket-Protocol| field in its handshake. If it including the |Sec-Websocket-Protocol| field in its handshake. If it
is specified, the server needs to include the same field and value in is specified, the server needs to include the same field and one of
its response for the connection to be established. the selected subprotocol values in its response for the connection to
be established.
These subprotocol names do not need to be registered, but if a These subprotocol names do not need to be registered, but if a
subprotocol is intended to be implemented by multiple independent subprotocol is intended to be implemented by multiple independent
WebSocket servers, potential clashes with the names of subprotocols WebSocket servers, potential clashes with the names of subprotocols
defined independently can be avoided by using names that contain the defined independently can be avoided by using names that contain the
domain name of the subprotocol's originator. For example, if Example domain name of the subprotocol's originator. For example, if Example
Corporation were to create a Chat subprotocol to be implemented by Corporation were to create a Chat subprotocol to be implemented by
many servers around the Web, they could name it "chat.example.com". many servers around the Web, they could name it "chat.example.com".
If the Example Organisation called their competing subprotocol If the Example Organisation called their competing subprotocol
"example.org's chat protocol", then the two subprotocols could be "example.org's chat protocol", then the two subprotocols could be
skipping to change at page 17, line 38 skipping to change at page 15, line 38
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
[ANSI.X3-4.1986].
*Converting a string to ASCII lowercase* means replacing all *Converting a string to ASCII lowercase* means replacing all
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) with the corresponding characters in the A to LATIN CAPITAL LETTER Z) with 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). 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
skipping to change at page 19, line 14 skipping to change at page 17, line 14
3. WebSocket URLs 3. WebSocket URLs
3.1. Parsing WebSocket URLs 3.1. Parsing WebSocket URLs
The steps to *parse a WebSocket URL's components* from a string /url/ The steps to *parse a WebSocket URL's components* from a string /url/
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 /url/ string is not an absolute URL, then fail this 1. If the /url/ string is not an absolute URL, then fail this
algorithm. [WEBADDRESSES] algorithm. [RFC3986] [RFC3987]
2. Resolve the /url/ string using the resolve a Web address 2. Resolve the /url/ 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
URL character encoding set to UTF-8. [WEBADDRESSES] [RFC3629] URL character encoding set to UTF-8. [RFC3629] [RFC3986]
[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 URL at this point. we already know it is an absolute URL at this point.
3. If /url/ does not have a <scheme> component whose value, when 3. If /url/ 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 /url/ has a <fragment> component, then fail this algorithm. 4. If /url/ has a <fragment> component, then fail this algorithm.
skipping to change at page 22, line 9 skipping to change at page 20, line 9
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
URL, but MUST NOT attempt to connect with such an unparsed URL, and URL, but MUST NOT attempt to connect with such an unparsed URL, 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
The base framing protocol is deliberately kept simple so that simple The base framing protocol defines a frame type with an opcode, a
implementations may ignore advanced features. In the absence of payload length, and designated locations for extension and
extensions negotiated during the opening handshake (Section 5), all application data, which together define the _payload_ data. Certain
reserved bits must be 0 and no reserved opcode values may be used. bits and opcodes are reserved for future expansion of the protocol.
As such, In the absence of extensions negotiated during the opening
handshake (Section 5), all reserved bits MUST be 0 and reserved
opcode values MUST NOT be used.
A data frame MAY be transmitted by either the client or the server at
any time after handshake completion and before that host has
generated a close message (Section 4.4.1).
4.2. Base Framing Protocol 4.2. Base Framing Protocol
The base framing protocol is defined by the following ABNF [RFC5234]: 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
framing is given in the following figure. [RFC5234]
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
+-+-+-+-+-------+-+-------------+-------------------------------+
|M|R|R|R| opcode|R| Payload len | Extended payload length |
|O|S|S|S| (4) |S| (7) | (16/63) |
|R|V|V|V| |V| | (if payload len==126/127) |
|E|1|2|3| |4| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| | Extension data |
+-------------------------------+ - - - - - - - - - - - - - - - +
: :
+---------------------------------------------------------------+
: Application data :
+---------------------------------------------------------------+
MORE: 1 bit
Indicates more fragments follow in the current message
RSV1, RSV2, RSV3, RSV4: 1 bit each
Must be 0 unless an extension is negotiated which defines meanings
for non-zero values
Opcode: 4 bits
Defines the interpretation of the payload data
Payload length: 7 bits
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
integer are the payload length. If 127, the following 8 bytes
interpreted as a 64-bit unsigned integer (the high bit must be 0)
are the payload length. Multibyte length quantities are expressed
in network byte order. The payload length is the length of the
Extension data + the length of the Application Data. The length
of the Extension data may be zero, in which case the Payload
length is the length of the Application data.
Extension data: n bytes
The extension data is 0 bytes unless there is a reserved op-code
or reserved bit present in the frame which indicates an extension
has been negotiated. Any extension MUST specify the length of the
extension data, or how that length may be calculated, and its use
MUST be negotiated during the handshake. If present, the
extension data is included in the total payload length.
Application data: n bytes
Arbitrary application data, taking up the remainder of the frame
after any extension data. The length of the Application data is
equal to the payload length minus the length of the Extension
data.
The base framing protocol is formally defined by the following ABNF
[RFC5234]:
ws-frame = frame-more ws-frame = frame-more
frame-rsv1 frame-rsv1
frame-rsv2 frame-rsv2
frame-rsv3 frame-rsv3
frame-opcode frame-opcode
frame-rsv4 frame-rsv4
frame-length frame-length
frame-extension frame-extension
application-data; application-data;
skipping to change at page 24, line 17 skipping to change at page 23, line 17
with the MORE bit set and the opcode set to 0, and terminated by a with the MORE bit set and the opcode set to 0, and terminated by a
single frame with the MORE bit clear and an opcode of 0. Its single frame with the MORE bit clear 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 from each of
those frames in order. those frames in order.
o _Note: There is an open question as to whether control frames be o _Note: There is an open question as to whether control frames be
interjected in the middle of a fragmented message. If so, it must interjected in the middle of a fragmented message. If so, it must
be decided whether they be fragmented (which would require keeping be decided whether they be fragmented (which would require keeping
a stack of "in-progress" messages)._ a stack of "in-progress" messages)._
o A sender MAY arbitrarily fragment a single message (which allows o A sender MAY create fragments of any size for non control
generation of dynamic content without having to buffer the data in messages.
order to count it).
o Clients and servers MUST support receiving both fragmented and o Clients and servers MUST support receiving both fragmented and
unfragmented messages. Messages sent as a single fragment may be unfragmented messages.
fragmented by intermediaries as per the item below, and as such
both sides must support receiving fragmented messages.
o An intermediary MAY fragment a message arbitrarily, except that it o An intermediary MAY change the fragmentation of a message if the
MUST NOT fragment or otherwise modify any message with any message uses only opcode and reserved bit values known to the
reserved bits set or using any reserved opcode, unless it observed intermediary.
the negotiation of an extension which it understands and which
defines the interpretation of those values.
4.4. Control Frames 4.4. Control Frames
The Close (0x01), Ping (0x02), and Pong (0x03) frames are contol Control frames have opcodes of 0x01 (Close), 0x02 (Ping), or 0x03
frames -- they do not supply data to the ultimate endpoint, but (Pong). Control frames are used to communicate state about the
instead are used to carry out tasks related to the WebSocket websocket.
connection itself.
A receiver MUST take the following action upon receiving control All control frames MUST be 125 bytes or less in length and MUST NOT
frames: be fragmented.
Close: 4.4.1. Close
Upon receipt of a close frame, an endpoint SHOULD send a Close The Close message contains an opcode of 0x01.
frame to the remote recipient, if it has not already done so,
deliver a close event to the application if necessary, and then
close the WebSocket.
Ping The application MUST NOT send any more data messages after sending a
close message.
Upon receipt of a Ping message, an endpoint SHOULD send a Pong A recevied close message is deemed to be an acknowledgement if the
response as soon as is practical. The Pong response MUST contain message body matches the body of a close message previously sent by
the payload provided in the Ping message, though an implementation the receiver. Otherwise the close message is a close initiated by
MAY truncate the message at an implementation-defined size which the sender.
MUST be at least 8 _(TBD)_ bytes.
Ping frames MAY be sent as a keep-alive mechanism, but if so the Upon receipt of an initiated close the endpoint MUST send a close
interval SHOULD be configurable. acknowledgment. It should do so as soon as is practical.
Pong The websocket is considered fully closed when an endpoint has either
received a close acknowledgment or sent a close acknowledgment.
If a Pong message is received without a matching Ping message 4.4.2. Ping
being sent, an endpoint MUST drop the connection. Otherwise, the
endpoint SHOULD update any liveness timer it may have for the The Ping message contains an opcode of 0x02.
connection.
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
bodies of the Ping and Pong MUST be the same.
4.4.3. Pong
The Pong message contains an opcode of 0x03.
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
bodies of the Ping and Pong MUST be the same.
4.5. Data Frames 4.5. Data Frames
All frame types not listed above are data frames, which transport All frame types not listed in Section 4.4 are data frames, which
application-layer data. The opcode determines the interpretation of transport application-layer data. The opcode determines the
the application data: interpretation of the application 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.
Additional data frame types will be defined in extensions or in a
subsequent version of the protocol.
4.6. Examples 4.6. Examples
_This section is non-normative._ _This section is non-normative._
o A single-frame text message o A single-frame text message
* 0x04 0x05 "Hello" * 0x04 0x05 "Hello"
o A fragmented text message o A fragmented text message
skipping to change at page 26, line 21 skipping to change at page 25, line 18
o 256 bytes binary message in a single frame o 256 bytes binary message in a single frame
* 0x05 0x7E 0x0100 [256 bytes of binary data] * 0x05 0x7E 0x0100 [256 bytes of binary data]
o 64KiB binary message in a single frame o 64KiB binary message in a single frame
* 0x05 0x7F 0x0000000000010000 [65536 bytes of binary data] * 0x05 0x7F 0x0000000000010000 [65536 bytes of binary data]
4.7. Extensibility 4.7. Extensibility
Extensions will be defined which extend the base protocol, but only The protocol is designed to allow for extensions, which will add
if their use is negotiated during the handshake. The following capabilities to the base protocols. The endpoints of a connection
mechanisms will be used for extension: MUST negotiate the use of any extensions during the handshake. This
specification provides opcodes 0x6 through 0xF, the extension data
field, and the frame-rsv1, frame-rsv2, frame-rsv3, and frame-rsv4
bits of the frame header for use by extensions. Below are some
anticipated uses of extensions. This list is neither 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 29, line 48 skipping to change at page 28, line 48
13. Add the string consisting of the concatenation of the string 13. Add the string consisting of the concatenation of the string
"Host:", a U+0020 SPACE character, and /hostport/, to /fields/. "Host:", a U+0020 SPACE character, and /hostport/, to /fields/.
14. Add the string consisting of the concatenation of the string 14. Add the string consisting of the concatenation of the string
"Origin:", a U+0020 SPACE character, and the /origin/ value, to "Origin:", a U+0020 SPACE character, and the /origin/ value, to
/fields/. /fields/.
15. Add the string "Sec-WebSocket-Draft: 2" to /fields/. 15. Add the string "Sec-WebSocket-Draft: 2" to /fields/.
16. If there is no /protocol/, then skip this step. 16. If there is no /protocols/, then skip this step.
Otherwise, add the string consisting of the concatenation of the Otherwise, generate the acceptable protocol string by joining
string "Sec-WebSocket-Protocol:", a U+0020 SPACE character, and each protocol in /protocols/ using a U+0020 SPACE character.
the /protocol/ value, to /fields/. Add the string consisting of the concatenation of the string
"Sec-WebSocket-Protocol:", a U+0020 SPACE character, and the
acceptable protocol string generated above, to /fields/.
17. If the client has any cookies that would be relevant to a 17. If the client has any cookies that would be relevant to a
resource accessed over HTTP, if /secure/ is false, or HTTPS, if resource accessed over HTTP, if /secure/ is false, or HTTPS, if
it is true, on host /host/, port /port/, with /resource name/ as it is true, on host /host/, port /port/, with /resource name/ as
the path (and possibly query parameters), then add to /fields/ the path (and possibly query parameters), then add to /fields/
any HTTP headers that would be appropriate for that information. any HTTP headers that would be appropriate for that information.
[RFC2616] [RFC2109] [RFC2965] [RFC2616] [RFC2109] [RFC2965]
This includes "HttpOnly" cookies (cookies with the http-only- This includes "HttpOnly" cookies (cookies with the http-only-
flag set to true); the WebSocket protocol is not considered a flag set to true); the WebSocket protocol is not considered a
skipping to change at page 35, line 29 skipping to change at page 34, line 29
If the value is not exactly equal to /origin/, then fail the If the value is not exactly equal to /origin/, then fail the
WebSocket connection and abort these steps. [ORIGIN] WebSocket connection and abort these steps. [ORIGIN]
-> If the entry's name is "sec-websocket-location" -> If the entry's name is "sec-websocket-location"
If the value is not exactly equal to a string obtained from If the value is not exactly equal to a string obtained from
the steps to construct a WebSocket URL from /host/, /port/, the steps to construct a WebSocket URL from /host/, /port/,
/resource name/, and the /secure/ flag, then fail the /resource name/, and the /secure/ flag, then fail the
WebSocket connection and abort these steps. WebSocket connection and abort these steps.
-> If the entry's name is "sec-websocket-protocol" -> If the entry's name is "sec-websocket-protocol"
If there was a /protocol/ specified, and the value is not If there was a /protocols/ string specified, and the value is
exactly equal to /protocol/, then fail the WebSocket not exactly equal to one of the items in /protocols/, then
connection and abort these steps. (If no /protocol/ was fail the WebSocket connection and abort these steps. (If no
specified, the field is ignored.) /protocols/ was specified, the field is ignored.)
-> If the entry's name is "set-cookie" or "set-cookie2" or -> If the entry's name is "set-cookie" or "set-cookie2" or
another cookie-related field name another cookie-related field name
If the relevant specification is supported by the user agent, If the relevant specification is supported by the user agent,
add the cookie, interpreted as defined by the appropriate add the cookie, interpreted as defined by the appropriate
specification, to the /list of cookies/, with the resource specification, to the /list of cookies/, with the resource
being the one with the host /host/, the port /port/, the path being the one with the host /host/, the port /port/, the path
(and possibly query parameters) /resource name/, and the (and possibly query parameters) /resource name/, and the
scheme |http| if /secure/ is false and |https| if /secure/ is scheme |http| if /secure/ is false and |https| if /secure/ is
true. [RFC2109] [RFC2965] true. [RFC2109] [RFC2965]
skipping to change at page 41, line 42 skipping to change at page 40, line 42
willing to communicate with, converted to ASCII lowercase. willing to communicate with, converted to ASCII lowercase.
If the server can respond to requests from multiple origins If the server can respond to requests from multiple origins
(or indeed, all origins), then the value should be derived (or indeed, all origins), then the value should be derived
from the client's handshake, specifically from the "Origin" from the client's handshake, specifically from the "Origin"
field. [ORIGIN] field. [ORIGIN]
/subprotocol/ /subprotocol/
Either null, or a string representing the subprotocol the Either null, or a string representing the subprotocol the
server is ready to use. If the server supports multiple server is ready to use. If the server supports multiple
subprotocols, then the value should be derived from the subprotocols, then the value should be derived from the
client's handshake, specifically from the "Sec-WebSocket- client's handshake, specifically by selecting one of the
Protocol" field. The absence of such a field is equivalent values from the "Sec-WebSocket-Protocol" field. The absence
to the null value. The empty string is not the same as the of such a field is equivalent to the null value. The empty
null value for these purposes. string is not the same as the null value for these purposes.
/key_1/ /key_1/
The value of the "Sec-WebSocket-Key1" field in the client's The value of the "Sec-WebSocket-Key1" field in the client's
handshake. handshake.
/key_2/ /key_2/
The value of the "Sec-WebSocket-Key2" field in the client's The value of the "Sec-WebSocket-Key2" field in the client's
handshake. handshake.
/key_3/ /key_3/
skipping to change at page 48, line 5 skipping to change at page 47, line 5
that the server has closed its connection, it must immediately close that the server has closed its connection, it must immediately close
its side of the connection also. Whether the user agent or the its side of the connection also. Whether the user agent or the
server closes the connection first, it is said that the *WebSocket server closes the connection first, it is said that the *WebSocket
connection is closed*. If the connection was closed after the client connection is closed*. If the connection was closed after the client
finished the WebSocket closing handshake, then the WebSocket finished the WebSocket closing handshake, then the WebSocket
connection is said to have been closed _cleanly_. connection is said to have been closed _cleanly_.
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. agents should not close the WebSocket connection arbitrarily.
8. Security considerations 8. Known extensions
Extensions provide a mechanism for implementations to opt-in to
additional protocol features. This section defines the meaning of
well-known extensions but implementations may use extensions defined
separately as well.
8.1. Compression
The registered extension token for this compression extension is
"deflate-stream".
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.
Senders using this extension MUST apply RFC 1951 encodings to all
bytes of the data stream following the handshake including both data
and control messages. The data stream MAY include multiple blocks of
both compressed and uncompressed types as defined by RFC 1951.
[RFC1951]
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
byte boundary. The encodings for adjacent messages MAY appear in the
same byte if no delay in transmission is occurred by doing so.
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.
skipping to change at page 49, line 5 skipping to change at page 49, line 5
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.
9. IANA considerations 10. IANA considerations
9.1. Registration of ws: scheme 10.1. Registration of ws: scheme
A |ws:| URL identifies a WebSocket server and resource name. A |ws:| URL 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.
skipping to change at page 50, line 17 skipping to change at page 50, line 17
Contact. Contact.
Ian Hickson <ian@hixie.ch> Ian Hickson <ian@hixie.ch>
Author/Change controller. Author/Change controller.
Ian Hickson <ian@hixie.ch> Ian Hickson <ian@hixie.ch>
References. References.
This document. This document.
9.2. Registration of wss: scheme 10.2. Registration of wss: scheme
A |wss:| URL identifies a WebSocket server and resource name, and A |wss:| URL 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.
skipping to change at page 51, line 24 skipping to change at page 51, line 24
Contact. Contact.
Ian Hickson <ian@hixie.ch> Ian Hickson <ian@hixie.ch>
Author/Change controller. Author/Change controller.
Ian Hickson <ian@hixie.ch> Ian Hickson <ian@hixie.ch>
References. References.
This document. This document.
9.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> Ian Hickson <ian@hixie.ch>
Contact. Contact.
Ian Hickson <ian@hixie.ch> Ian Hickson <ian@hixie.ch>
References. References.
This document. This document.
9.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2 10.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2
This section describes two header fields for registration in the This section describes two header fields for registration in the
Permanent Message Header Field Registry. [RFC3864] Permanent Message Header Field Registry. [RFC3864]
Header field name Header field name
Sec-WebSocket-Key1 Sec-WebSocket-Key1
Applicable protocol Applicable protocol
http http
skipping to change at page 52, line 43 skipping to change at page 52, line 43
None. None.
The |Sec-WebSocket-Key1| and |Sec-WebSocket-Key2| headers are used in The |Sec-WebSocket-Key1| and |Sec-WebSocket-Key2| headers are used in
the WebSocket handshake. They are sent from the client to the server the WebSocket handshake. They are sent from the client to the server
to provide part of the information used by the server to prove that to provide part of the information used by the server to prove that
it received a valid WebSocket handshake. This helps ensure that the it received a valid WebSocket handshake. This helps ensure that the
server does not accept connections from non-Web-Socket clients (e.g. server does not accept connections from non-Web-Socket clients (e.g.
HTTP clients) that are being abused to send data to unsuspecting HTTP clients) that are being abused to send data to unsuspecting
WebSocket servers. WebSocket servers.
9.5. Sec-WebSocket-Location 10.5. Sec-WebSocket-Location
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-Location Sec-WebSocket-Location
Applicable protocol Applicable protocol
http http
skipping to change at page 53, line 27 skipping to change at page 53, line 27
Related information Related information
None. None.
The |Sec-WebSocket-Location| header is used in the WebSocket The |Sec-WebSocket-Location| header is used in the WebSocket
handshake. It is sent from the server to the client to confirm the handshake. It is sent from the server to the client to confirm the
URL of the connection. This enables the client to verify that the URL of the connection. This enables the client to verify that the
connection was established to the right server, port, and path, connection was established to the right server, port, and path,
instead of relying on the server to verify that the requested host, instead of relying on the server to verify that the requested host,
port, and path are correct. port, and path are correct.
9.6. Sec-WebSocket-Origin 10.6. 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
skipping to change at page 54, line 7 skipping to change at page 54, line 7
Related information Related information
None. None.
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.
9.7. Sec-WebSocket-Protocol 10.7. 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
skipping to change at page 54, line 36 skipping to change at page 54, line 36
Related information Related information
None. None.
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.
9.8. Sec-WebSocket-Draft 10.8. Sec-WebSocket-Draft
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-Draft Sec-WebSocket-Draft
Applicable protocol Applicable protocol
http http
skipping to change at page 56, line 5 skipping to change at page 56, line 5
Related information Related information
None. None.
The |Sec-WebSocket-Draft| header is used in the WebSocket handshake. The |Sec-WebSocket-Draft| header is used in the WebSocket handshake.
It is sent from the client to the server to indicate the draft It is sent from the client to the server to indicate the draft
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.
10. Using the WebSocket protocol from other specifications 11. Using the WebSocket protocol from other specifications
The WebSocket protocol is intended to be used by another The WebSocket protocol is intended to be used by another
specification to provide a generic mechanism for dynamic author- specification to provide a generic mechanism for dynamic author-
defined content, e.g. in a specification defining a scripted API. defined content, e.g. in a specification defining a scripted API.
Such a specification first needs to "establish a WebSocket Such a specification first needs to "establish a WebSocket
connection", providing that algorithm with: connection", providing that algorithm with:
o The destination, consisting of a /host/ and a /port/. o The destination, consisting of a /host/ and a /port/.
skipping to change at page 57, line 5 skipping to change at page 57, line 5
When the connection is closed, for any reason including failure to When the connection is closed, for any reason including failure to
establish the connection in the first place, it is said that the establish the connection in the first place, it is said that the
"WebSocket connection is closed". "WebSocket connection is closed".
While a connection is open, the specification will need to handle the While a connection is open, the specification will need to handle the
cases when "a WebSocket message has been received" with text /data/. cases when "a WebSocket message has been received" with text /data/.
To send some text /data/ to an open connection, the specification To send some text /data/ to an open connection, the specification
needs to "send /data/ using the WebSocket". needs to "send /data/ using the WebSocket".
11. Acknowledgements 12. Acknowledgements
Special thanks are due to Ian Hickson, who was the original author Special thanks are due to Ian Hickson, who was the original author
and editor of this protocol. The initial design of this and editor of this protocol. The initial design of this
specification benefitted from the participation of many people in the specification benefitted from the participation of many people in the
WHATWG and WHATWG mailing list. Contributions to that specification WHATWG and WHATWG mailing list. Contributions to that specification
are not tracked by section, but a list of all who contributed to that are not tracked by section, but a list of all who contributed to that
specification is given in the WHATWG HTML specification. [HTML] specification is given in the WHATWG HTML specification. [HTML]
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.
12. Normative References 13. Normative References
[HTML] Hickson, I., "HTML", August 2010, [HTML] Hickson, I., "HTML", August 2010,
<http://whatwg.org/html5>. <http://whatwg.org/html5>.
[ORIGIN] Barth, A., Jackson, C., and I. Hickson, "The HTTP Origin [ORIGIN] Barth, A., Jackson, C., and I. Hickson, "The HTTP Origin
Header", draft-abarth-origin (work in progress), Header", draft-abarth-origin (work in progress),
September 2009, September 2009,
<http://tools.ietf.org/html/draft-abarth-origin>. <http://tools.ietf.org/html/draft-abarth-origin>.
[ANSI.X3-4.1986]
American National Standards Institute, "Coded Character
Set - 7-bit American Standard Code for Information
Interchange", ANSI X3.4, 1986.
[RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, [RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321,
April 1992. April 1992.
[RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification
version 1.3", RFC 1951, May 1996.
[RFC2109] Kristol, D. and L. Montulli, "HTTP State Management [RFC2109] Kristol, D. and L. Montulli, "HTTP State Management
Mechanism", RFC 2109, February 1997. Mechanism", RFC 2109, February 1997.
[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", [RFC2246] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0",
RFC 2246, January 1999. RFC 2246, January 1999.
[RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
skipping to change at page 59, line 10 skipping to change at page 59, line 19
[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., [RFC4366] Blake-Wilson, S., Nystrom, M., Hopwood, D., Mikkelsen, J.,
and T. Wright, "Transport Layer Security (TLS) and T. Wright, "Transport Layer Security (TLS)
Extensions", RFC 4366, April 2006. Extensions", RFC 4366, April 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.
[WEBADDRESSES]
Connolly, D. and C. Sperberg-McQueen, "Web addresses in
HTML 5", May 2009, <http://www.w3.org/html/wg/href/draft>.
[WSAPI] Hickson, I., "The Web Sockets API", August 2010, [WSAPI] Hickson, I., "The Web Sockets API", August 2010,
<http://dev.w3.org/html5/websockets/>. <http://dev.w3.org/html5/websockets/>.
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. 52 change blocks. 
218 lines changed or deleted 268 lines changed or added

This html diff was produced by rfcdiff 1.40. The latest version is available from http://tools.ietf.org/tools/rfcdiff/