draft-ietf-hybi-thewebsocketprotocol-03.txt   draft-ietf-hybi-thewebsocketprotocol-04.txt 
HyBi Working Group I. Fette HyBi Working Group I. Fette
Internet-Draft Google, Inc. Internet-Draft Google, Inc.
Intended status: Standards Track October 17, 2010 Intended status: Standards Track January 11, 2011
Expires: April 20, 2011 Expires: July 15, 2011
The WebSocket protocol The WebSocket protocol
draft-ietf-hybi-thewebsocketprotocol-03 draft-ietf-hybi-thewebsocketprotocol-04
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
applications that need two-way communication with servers that does applications that need two-way communication with servers that does
not rely on opening multiple HTTP connections (e.g. using not rely on opening multiple HTTP connections (e.g. using
XMLHttpRequest or <iframe>s and long polling). XMLHttpRequest or <iframe>s and long polling).
Please send feedback to the hybi@ietf.org mailing list. Please send feedback to the hybi@ietf.org mailing list.
Note
This draft is meant to reflect changes in direction in the HyBi
working group. There is not yet consensus on everything in this
draft. Specifically, details about the framing are still under
discussion, however this draft is much closer to what the group is
discussing than the previous draft. There have also been proposals
to change the handshake, so the handshake is also not in a final
form.
Status of this Memo Status of this Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
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 April 20, 2011. This Internet-Draft will expire on July 15, 2011.
Copyright Notice Copyright Notice
Copyright (c) 2010 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
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
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 . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 5 1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 4
1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 8 1.3. Opening handshake . . . . . . . . . . . . . . . . . . . . 6
1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 11 1.4. Closing handshake . . . . . . . . . . . . . . . . . . . . 8
1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 12 1.5. Design philosophy . . . . . . . . . . . . . . . . . . . . 9
1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 12 1.6. Security model . . . . . . . . . . . . . . . . . . . . . . 9
1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 13 1.7. Relationship to TCP and HTTP . . . . . . . . . . . . . . . 10
1.8. Establishing a connection . . . . . . . . . . . . . . . . 13 1.8. Establishing a connection . . . . . . . . . . . . . . . . 10
1.9. Subprotocols using the WebSocket protocol . . . . . . . . 14 1.9. Subprotocols using the WebSocket protocol . . . . . . . . 11
2. Conformance requirements . . . . . . . . . . . . . . . . . . . 15 2. Conformance requirements . . . . . . . . . . . . . . . . . . . 12
2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 15 2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 12
3. WebSocket URLs . . . . . . . . . . . . . . . . . . . . . . . . 17 3. WebSocket URLs . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1. Parsing WebSocket URLs . . . . . . . . . . . . . . . . . . 17 3.1. Parsing WebSocket URLs . . . . . . . . . . . . . . . . . . 14
3.2. Constructing WebSocket URLs . . . . . . . . . . . . . . . 18 3.2. Constructing WebSocket URLs . . . . . . . . . . . . . . . 15
3.3. Valid WebSocket URLs . . . . . . . . . . . . . . . . . . . 18 3.3. Valid WebSocket URLs . . . . . . . . . . . . . . . . . . . 15
4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 20 4. Data Framing . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2. Base Framing Protocol . . . . . . . . . . . . . . . . . . 20 4.2. Client-to-Server Masking . . . . . . . . . . . . . . . . . 17
4.3. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 22 4.3. Base Framing Protocol . . . . . . . . . . . . . . . . . . 18
4.4. Control Frames . . . . . . . . . . . . . . . . . . . . . . 23 4.4. Fragmentation . . . . . . . . . . . . . . . . . . . . . . 21
4.4.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 23 4.5. Control Frames . . . . . . . . . . . . . . . . . . . . . . 22
4.4.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.5.1. Close . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.5.2. Ping . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.5. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 24 4.5.3. Pong . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.6. Data Frames . . . . . . . . . . . . . . . . . . . . . . . 23
4.7. Extensibility . . . . . . . . . . . . . . . . . . . . . . 25 4.7. Examples . . . . . . . . . . . . . . . . . . . . . . . . . 23
5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 26 4.8. Extensibility . . . . . . . . . . . . . . . . . . . . . . 24
5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 26 5. Opening Handshake . . . . . . . . . . . . . . . . . . . . . . 25
5.2. Server-side requirements . . . . . . . . . . . . . . . . . 36 5.1. Client Requirements . . . . . . . . . . . . . . . . . . . 25
5.2.1. Reading the client's opening handshake . . . . . . . . 36 5.2. Server-side requirements . . . . . . . . . . . . . . . . . 29
5.2.2. Sending the server's opening handshake . . . . . . . . 39 5.2.1. Reading the client's opening handshake . . . . . . . . 29
6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 44 5.2.2. Sending the server's opening handshake . . . . . . . . 30
6.1. Handling errors in UTF-8 from the server . . . . . . . . . 44 6. Error Handling . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2. Handling errors in UTF-8 from the client . . . . . . . . . 44 6.1. Handling errors in UTF-8 from the server . . . . . . . . . 33
7. Closing the connection . . . . . . . . . . . . . . . . . . . . 45 6.2. Handling errors in UTF-8 from the client . . . . . . . . . 33
7.1. Client-initiated closure . . . . . . . . . . . . . . . . . 45 7. Closing the connection . . . . . . . . . . . . . . . . . . . . 34
7.2. Server-initiated closure . . . . . . . . . . . . . . . . . 45 7.1. Client-initiated closure . . . . . . . . . . . . . . . . . 34
7.3. Closure . . . . . . . . . . . . . . . . . . . . . . . . . 45 7.2. Server-initiated closure . . . . . . . . . . . . . . . . . 34
8. Known extensions . . . . . . . . . . . . . . . . . . . . . . . 47 7.3. Closure . . . . . . . . . . . . . . . . . . . . . . . . . 34
8.1. Compression . . . . . . . . . . . . . . . . . . . . . . . 47 8. Known extensions . . . . . . . . . . . . . . . . . . . . . . . 36
9. Security considerations . . . . . . . . . . . . . . . . . . . 48 8.1. Compression . . . . . . . . . . . . . . . . . . . . . . . 36
10. IANA considerations . . . . . . . . . . . . . . . . . . . . . 49 9. Security considerations . . . . . . . . . . . . . . . . . . . 37
10.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 49 10. IANA considerations . . . . . . . . . . . . . . . . . . . . . 38
10.2. Registration of wss: scheme . . . . . . . . . . . . . . . 50 10.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 38
10.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 51 10.2. Registration of wss: scheme . . . . . . . . . . . . . . . 39
10.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2 . . . . . . . . 51 10.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 40
10.5. Sec-WebSocket-Location . . . . . . . . . . . . . . . . . . 52 10.4. Sec-WebSocket-Key and Sec-WebSocket-Nonce . . . . . . . . 40
10.6. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 53 10.5. Sec-WebSocket-Location . . . . . . . . . . . . . . . . . . 41
10.7. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 54 10.6. Sec-WebSocket-Origin . . . . . . . . . . . . . . . . . . . 42
10.8. Sec-WebSocket-Draft . . . . . . . . . . . . . . . . . . . 54 10.7. Sec-WebSocket-Protocol . . . . . . . . . . . . . . . . . . 43
11. Using the WebSocket protocol from other specifications . . . . 56 10.8. Sec-WebSocket-Version . . . . . . . . . . . . . . . . . . 43
12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 57 11. Using the WebSocket protocol from other specifications . . . . 45
13. Normative References . . . . . . . . . . . . . . . . . . . . . 58 12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 46
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 60 13. Normative References . . . . . . . . . . . . . . . . . . . . . 47
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 49
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.
skipping to change at page 6, line 5 skipping to change at page 4, line 46
etc. etc.
1.2. Protocol overview 1.2. Protocol overview
_This section is non-normative._ _This section is non-normative._
The protocol has two parts: a handshake, and then the data transfer. The protocol has two parts: a handshake, and then the data transfer.
The handshake from the client looks as follows: The handshake from the client looks as follows:
GET /demo HTTP/1.1 GET /chat HTTP/1.1
Host: example.com Host: server.example.com
Upgrade: websocket
Connection: Upgrade Connection: Upgrade
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Protocol: sample Sec-WebSocket-Origin: http://example.com
Upgrade: WebSocket Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Version: 4
Origin: http://example.com
^n:ds[4U
The handshake from the server looks as follows: The handshake from the server looks as follows:
HTTP/1.1 101 WebSocket Protocol Handshake HTTP/1.1 101 Switching Protocols
Upgrade: WebSocket Upgrade: websocket
Connection: Upgrade Connection: Upgrade
Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Accept: me89jWimTRKTWwrS3aRrL53YZSo=
Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Nonce: AQIDBAUGBwgJCgsMDQ4PEC==
Sec-WebSocket-Protocol: sample Sec-WebSocket-Protocol: chat
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 [RFC2616].
specification.
After the leading line in both cases come an unordered ASCII case-
insensitive set of fields, one per line, that each match the
following non-normative ABNF: [RFC5234] [ANSI.X3-4.1986]
field = 1*name-char colon [ space ] *any-char cr lf
colon = %x003A ; U+003A COLON (:)
space = %x0020 ; U+0020 SPACE
cr = %x000D ; U+000D CARRIAGE RETURN (CR)
lf = %x000A ; U+000A LINE FEED (LF)
name-char = %x0000-0009
/ %x000B-000C
/ %x000E-0039
/ %x003B-10FFFF
; a Unicode character other than
; U+000A LINE FEED (LF),
; U+000D CARRIAGE RETURN (CR),
; or U+003A COLON (:)
any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF
; a Unicode character other than
; U+000A LINE FEED (LF)
; or U+000D CARRIAGE RETURN (CR)
NOTE: The character set for the above ABNF is Unicode. The fields
themselves are encoded as UTF-8.
Lines that don't match the above production cause the connection to
be aborted.
Finally, after the last field, the client sends 10 bytes starting After the leading line in both cases come an unordered set of
with 0x0D 0x0A and followed by 8 random bytes, part of a challenge, headers. The meaning of these headers is specified in Section 5 of
and the server sends 18 bytes starting with 0x0D 0x0A and followed by this document. Additional headers may also be present, such as
16 bytes consisting of a challenge response. The details of this cookies required to identify the user. The format and parsing of
challenge and other parts of the handshake are described in the next headers is as defined in [RFC2616].
section.
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
skipping to change at page 8, line 8 skipping to change at page 5, line 45
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. 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 signaling, such as to signal that the connection should be
closed. This version of the protocol defines six frame types and closed. This version of the protocol defines six frame types and
leaves ten reserved for future use. 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._
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 and intermediaries, so that a single port can be
clients talking to that server and WebSocket clients talking to that used by both HTTP clients talking to that server and WebSocket
server. To this end, the WebSocket client's handshake appears to clients talking to that server. To this end, the WebSocket client's
HTTP servers to be a regular GET request with an Upgrade offer: handshake is an HTTP Upgrade request:
GET / HTTP/1.1 GET /chat HTTP/1.1
Upgrade: WebSocket Host: server.example.com
Upgrade: websocket
Connection: Upgrade Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 4
Fields in the handshake are sent by the client in a random order; the Headers in the handshake are sent by the client in a random order;
order is not meaningful. the order is not meaningful.
Additional fields are used to select options in the WebSocket
protocol. The only options available in this version are the
subprotocol selector, |Sec-WebSocket-Protocol|, and |Cookie|, which
can used for sending cookies to the server (e.g. as an authentication
mechanism). The |Sec-WebSocket-Protocol| request-header field can be
used to indicate what subprotocols (application-level protocols
layered over the WebSocket protocol) are acceptable to the client.
The server selects one of the acceptable protocols and echoes that
value in its handshake to indicate that it has selected that
protocol.
Sec-WebSocket-Protocol: chat superchat
The other fields in the handshake are all security-related. The
|Host| field is used to protect against DNS rebinding attacks and to
allow multiple domains to be served from one IP address.
Host: example.com Additional headers are used to select options in the WebSocket
protocol. Options available in this version are the subprotocol
selector, |Sec-WebSocket-Protocol|, and |Cookie|, which can used for
sending cookies to the server (e.g. as an authentication mechanism).
The |Sec-WebSocket-Protocol| request-header field can be used to
indicate what subprotocols (application-level protocols layered over
the WebSocket protocol) are acceptable to the client. The server
selects one of the acceptable protocols and echoes that value in its
handshake to indicate that it has selected that protocol.
Sec-WebSocket-Protocol: chat
The server includes the hostname in the |Sec-WebSocket-Location| The "Request-URI" of the GET method [RFC2616] is used to identify the
field of its handshake, so that both the client and the server can endpoint of the WebSocket connection, both to allow multiple domains
verify that they agree on which host is in use. to be served from one IP address and to allow multiple WebSocket
endpoints to be served by a single server.
The |Origin| field is used to protect against unauthorized cross- The client includes the hostname in the Host header of its handshake
origin use of a WebSocket server by scripts using the |WebSocket| API as per [RFC2616], so that both the client and the server can verify
in a Web browser. The server specifies which origin it is willing to that they agree on which host is in use.
receive requests from by including a |Sec-WebSocket-Origin| field
with that origin. If multiple origins are authorized, the server
echoes the value in the |Origin| field of the client's handshake.
Origin: http://example.com The |Sec-WebSocket-Origin| header is used to protect against
unauthorized cross-origin use of a WebSocket server by scripts using
the |WebSocket| API in a Web browser. The server is informed of the
script origin generating the WebSocket connection request. If the
server does not wish to accept connections from this origin, it can
choose to abort the connection.
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
client's WebSocket handshake, so that the server doesn't accept client's WebSocket handshake, so that the server doesn't accept
connections that are not WebSocket connections. This prevents an connections that are not WebSocket connections. This prevents an
attacker from tricking a WebSocket server by sending it carefully- attacker from tricking a WebSocket server by sending it carefully-
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 To prove that the handshake was received, the server has to take two
three pieces of information and combine them to form a response. The pieces of information and combine them to form a response. The first
first two pieces of information come from the |Sec-WebSocket-Key1| piece of information comes from the |Sec-WebSocket-Key| header in the
and |Sec-WebSocket-Key2| fields in the client handshake: client handshake:
Sec-WebSocket-Key1: 18x 6]8vM;54 *(5: { U1]8 z [ 8
Sec-WebSocket-Key2: 1_ tx7X d < nw 334J702) 7]o}` 0
For each of these fields, the server has to take the digits from the
value to obtain a number (in this case 1868545188 and 1733470270
respectively), then divide that number by the number of spaces
characters in the value (in this case 12 and 10) to obtain a 32-bit
number (155712099 and 173347027). These two resulting numbers are
then used in the server handshake, as described below.
The counting of spaces is intended to make it impossible to smuggle
this field into the resource name; making this even harder is the
presence of _two_ such fields, and the use of a newline as the only
reliable indicator that the end of the key has been reached. The use
of random characters interspersed with the spaces and the numbers
ensures that the implementor actually looks for spaces and newlines,
instead of being treating any character like a space, which would
make it again easy to smuggle the fields into the path and trick the
server. Finally, _dividing_ by this number of spaces is intended to
make sure that even the most naive of implementations will check for
spaces, since if ther server does not verify that there are some
spaces, the server will try to divide by zero, which is usually fatal
(a correct handshake will always have at least one space).
The third piece of information is given after the fields, in the last Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
eight bytes of the handshake, expressed here as they would be seen if
interpreted as UTF-8:
Tm[K T2u 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
the GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" in string form, which
is unlikely to be used by network endpoints that do not understand
the WebSocket protocol. A SHA-1 hash, base64-encoded, of this
concatenation is then returned in the server's handshake
[FIPS.180-2.2002].
The concatenation of the number obtained from processing the |Sec- Concretely, if as in the example above, header |Sec-WebSocket-Key|
WebSocket-Key1| field, expressed as a big-endian 32 bit number, the had the value "dGhlIHNhbXBsZSBub25jZQ==", the server would
number obtained from processing the |Sec-WebSocket-Key2| field, again concatenate the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" to form
expressed as a big-endian 32 bit number, and finally the eight bytes the string "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-
at the end of the handshake, form a 128 bit string whose MD5 sum is C5AB0DC85B11". The server would then take the SHA-1 hash of this,
then used by the server to prove that it read the handshake. 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
then base64-encoded, to give the value "s3pPLMBiTxaQ9kYGzzhZRbK+
xOo=".
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 (the HTTP version and reason phrase aren't important): code 101:
HTTP/1.1 101 WebSocket Protocol Handshake HTTP/1.1 101 Switching Protocols
The fields follow. Two of the fields are just for compatibility with Any status code other than 101 must be treated as a failure and the
HTTP: websocket connection aborted. The headers follow the status code.
Upgrade: WebSocket The |Connection| and |Upgrade| headers complete the HTTP Upgrade.
Connection: Upgrade
Two of the fields are part of the security model described above, The |Sec-WebSocket-Accept| header indicates whether the server is
echoing the origin and stating the exact host, port, resource name, willing to accept the connection. If present, this header must
and whether the connection is expected to be encrypted: include a hash of the client's nonce sent in |Sec-WebSocket-Key|
along with a predefined GUID. Any other value must not be
interpreted as an acceptance of the connection by the server.
Sec-WebSocket-Origin: http://example.com HTTP/1.1 101 Switching Protocols
Sec-WebSocket-Location: ws://example.com/ Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: me89jWimTRKTWwrS3aRrL53YZSo=
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. If the |Sec-WebSocket-Accept|
one origin and only serves one resource can therefore just return value does not match the expected value, or if the header is missing,
hard-coded values and does not need to parse the client's handshake or if the HTTP status code is not 101, the connection will not be
to verify the correctness of the values. 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| constructor. A server that speaks multiple subprotocols
has to 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 it 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
byte (128 bit) value, shown here as if interpreted as UTF-8:
fQJ,fN/4F4!~K~MH
This value depends on what the client sends, as described above. If
it doesn't match what the client is expecting, the client would
disconnect.
Having part of the handshake appear after the fields ensures that
both the server and the client verify that the connection is not
being interrupted by an HTTP intermediary such as a man-in-the-middle
cache or proxy.
1.4. Closing handshake 1.4. Closing handshake
_This section is non-normative._ _This section is non-normative._
The closing handshake is far simpler than the opening handshake. The closing handshake is far simpler than the opening handshake.
Either peer can send a control frame with data containing a specified Either peer can send a control frame with data containing a specified
control sequence to begin the closing handshake. Upon receiving such control sequence to begin the closing handshake. Upon receiving such
a frame, the other peer sends an identical frame in acknowledgement, a frame, the other peer sends an identical frame in acknowledgement,
if it hasn't already sent one. Upon receiving _that_ control frame, if it hasn't already sent one. Upon receiving _that_ control frame,
the first peer then closes the connection, safe in the knowledge that the first peer then closes the connection, safe in the knowledge that
no further data is forthcoming. no further data is forthcoming.
After sending a control frame indicating the connection should be After sending a control frame indicating the connection should be
closed, a peer does not send any further data; after receiving a closed, a peer does not send any further data; after receiving a
control frame frame indicating the connection should be closed, a control frame indicating the connection should be closed, a peer
peer 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.
1.5. Design philosophy 1.5. Design philosophy
skipping to change at page 12, line 22 skipping to change at page 9, line 29
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
layer, in the same way that metadata is layered on top of TCP by the layer, in the same way that metadata is layered on top of TCP by the
application layer (HTTP). application layer (HTTP).
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 mechanism that TCP is built on, but without length limits; and re-
reimplements 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
handshake also. handshake also.
The protocol is intended to be extensible; future versions will The protocol is intended to be extensible; future versions will
likely introduce a mechanism to compress data and might support likely introduce a mechanism to compress data and might support
sending binary data. sending binary data.
skipping to change at page 13, line 35 skipping to change at page 10, line 41
and port 443 for WebSocket connections tunneled over TLS. and port 443 for WebSocket connections tunneled over TLS.
1.8. Establishing a connection 1.8. Establishing a connection
_This section is non-normative._ _This section is non-normative._
There are several options for establishing a WebSocket connection. There are several options for establishing a WebSocket connection.
On the face of it, the simplest method would seem to be to use port On the face of it, the simplest method would seem to be to use port
80 to get a direct connection to a WebSocket server. Port 80 80 to get a direct connection to a WebSocket server. Port 80
traffic, however, will often be intercepted by man-in-the-middle HTTP traffic, however, will often be intercepted by HTTP proxies, which
proxies, which can lead to the connection failing to be established. can lead to the connection failing to be established.
The most reliable method, therefore, is to use TLS encryption and The most reliable method, therefore, is to use TLS encryption and
port 443 to connect directly to a WebSocket server. This has the port 443 to connect directly to a WebSocket server. This has the
advantage of being more secure; however, TLS encryption can be advantage of being more secure; however, TLS encryption can be
computationally expensive. computationally expensive.
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
skipping to change at page 14, line 22 skipping to change at page 11, line 29
the selected subprotocol values in its response for the connection to the selected subprotocol values in its response for the connection to
be established. 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 Organization 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
implemented by servers simultaneously, with the server dynamically implemented by servers simultaneously, with the server dynamically
selecting which subprotocol to use based on the value sent by the selecting which subprotocol to use based on the value sent by the
client. client.
Subprotocols can be versioned in backwards-incompatible ways by Subprotocols can be versioned in backwards-incompatible ways by
changing the subprotocol name, eg. going from "bookings.example.net" changing the subprotocol name, e.g. going from "bookings.example.net"
to "v2.bookings.example.net". These subprotocols would be considered to "v2.bookings.example.net". These subprotocols would be considered
completely separate by WebSocket clients. Backwards-compatible completely separate by WebSocket clients. Backwards-compatible
versioning can be implemented by reusing the same subprotocol string versioning can be implemented by reusing the same subprotocol string
but carefully designing the actual subprotocol to support this kind but carefully designing the actual subprotocol to support this kind
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.
skipping to change at page 20, line 9 skipping to change at page 17, 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
In the WebSocket protocol, data is transmitted using a sequence of
frames. Frames sent from the client to the server are masked to
avoid confusing network intermediaries, such as intercepting proxies.
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 host has any time after handshake completion and before that host has
generated a close message (Section 4.4.1). generated a close message (Section 4.5.1).
4.2. Base Framing Protocol 4.2. Client-to-Server Masking
The client MUST mask all frames sent to the server.
The masking-key is derived from information exchanged between the
client and the server in the handshake and is constant for the
duration of the WebSocket connection.
The masking-key is the SHA-1 hash of the concatenation of the value
of the Sec-WebSocket-Key header (sent from the client to the server),
the value of the Sec-WebSocket-Nonce header (sent from the server to
the client), and the string "61AC5F19-FBBA-4540-B96F-6561F1AB40A8"
(which is unique to the web socket protocol).
For example, if the Sec-WebSocket-Key header contains the value
"dGhlIHNhbXBsZSBub25jZQ==" and the Sec-WebSocket-Nonce header
contains the value "AQIDBAUGBwgJCgsMDQ4PEC==", the masking key is the
SHA-1 hash of the string "dGhlIHNhbXBsZSBub25jZQ==AQIDBAUGBwgJCgsMDQ4
PEC==61AC5F19-FBBA-4540-B96F-6561F1AB40A8", which is the sequence of
octets 0x41 0xe1 0x4f 0x78 0x31 0x1e 0x4c 0x34 0x28 0x3e 0x6d 0x8b
0x36 0x3b 0x88 0x48 0xd5 0x85 0x91 0xa7.
Each masked frame consists of a 32-bit masking-nonce followed by
masked-data:
masked-frame = masking-nonce masked-data
masking-nonce = 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.
1. Let the frame-key be the SHA-1 hash of the concatentation of the
masking-nonce followed by the masking-key.
2. Octet i of the masked-data is the XOR of octet i of the clear
text frame with octet i modulo 20 of the frame-key:
frame-key = SHA-1(masking-nonce || masking-key)
j = i MOD 20
masked-octet-i = clear-text-octet-i XOR octet-j-of-frame-key
When preparing a masked-frame, the client MUST pick a fresh masking-
nonce 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 given in detail in this section. A high level overview of the
framing is given in the following figure. [RFC5234] framing is given in the following figure. [RFC5234]
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
+-+-+-+-+-------+-+-------------+-------------------------------+ +-+-+-+-+-------+-+-------------+-------------------------------+
|M|R|R|R| opcode|R| Payload len | Extended payload length | |F|R|R|R| opcode|R| Payload len | Extended payload length |
|O|S|S|S| (4) |S| (7) | (16/63) | |I|S|S|S| (4) |S| (7) | (16/63) |
|R|V|V|V| |V| | (if payload len==126/127) | |N|V|V|V| |V| | (if payload len==126/127) |
|E|1|2|3| |4| | | | |1|2|3| |4| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 | | Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+ + - - - - - - - - - - - - - - - +-------------------------------+
| | Extension data | | | Extension data |
+-------------------------------+ - - - - - - - - - - - - - - - + +-------------------------------+ - - - - - - - - - - - - - - - +
: : : :
+---------------------------------------------------------------+ +---------------------------------------------------------------+
: Application data : : Application data :
+---------------------------------------------------------------+ +---------------------------------------------------------------+
MORE: 1 bit FIN: 1 bit
Indicates more fragments follow in the current message Indicates that this is the final fragment in a message. The first
fragment may also be the final fragment.
RSV1, RSV2, RSV3, RSV4: 1 bit each RSV1, RSV2, RSV3, RSV4: 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
skipping to change at page 22, line 46 skipping to change at page 21, line 46
/ %x7F frame-length-63 / %x7F frame-length-63
frame-length-16 = %x0000-FFFF frame-length-16 = %x0000-FFFF
frame-length-63 = %x0000000000000000-7FFFFFFFFFFFFFFF frame-length-63 = %x0000000000000000-7FFFFFFFFFFFFFFF
frame-extension = *( %x00-FF ) ; to be defined later frame-extension = *( %x00-FF ) ; to be defined later
application-data = *( %x00-FF ) application-data = *( %x00-FF )
4.3. Fragmentation 4.4. Fragmentation
The following rules apply to fragmentation: The following rules apply to fragmentation:
o An unfragmented message consists of a single frame with the MORE o An unfragmented message consists of a single frame with the FIN
bit clear 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 MORE bit o A fragmented message consists of a single frame with the FIN bit
set 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 MORE bit set and the opcode set to 0, and terminated by a with the FIN bit clear and the opcode set to 0, and terminated by
single frame with the MORE bit clear 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 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 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 An intermediary MAY change the fragmentation of a message if the
message uses only opcode and reserved bit values known to the message uses only opcode and reserved bit values known to the
intermediary. intermediary.
4.4. Control Frames 4.5. Control Frames
Control frames have opcodes of 0x01 (Close), 0x02 (Ping), or 0x03 Control frames have opcodes of 0x01 (Close), 0x02 (Ping), or 0x03
(Pong). Control frames are used to communicate state about the (Pong). Control frames are used to communicate state about the
websocket. websocket.
All control frames MUST be 125 bytes or less in length and MUST NOT All control frames MUST be 125 bytes or less in length and MUST NOT
be fragmented. be fragmented.
4.4.1. Close 4.5.1. Close
The Close message contains an opcode of 0x01. The Close message contains an opcode of 0x01.
The application MUST NOT send any more data messages after sending a The application MUST NOT send any more data messages after sending a
close message. close message.
A recevied close message is deemed to be an acknowledgement if the A received close message is deemed to be an acknowledgement if the
message body matches the body of a close message previously sent by message body matches the body of a close message previously sent by
the receiver. Otherwise the close message is a close initiated by the receiver. Otherwise the close message is a close initiated by
the sender. the sender.
Upon receipt of an initiated close the endpoint MUST send a close Upon receipt of an initiated close the endpoint MUST send a close
acknowledgment. It should do so as soon as is practical. acknowledgment. It should do so as soon as is practical.
The websocket is considered fully closed when an endpoint has either The websocket is considered fully closed when an endpoint has either
received a close acknowledgment or sent a close acknowledgment. received a close acknowledgment or sent a close acknowledgment.
4.4.2. Ping 4.5.2. Ping
The Ping message contains an opcode of 0x02. The Ping message contains an opcode of 0x02.
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 of the Ping and Pong MUST be the same.
4.4.3. Pong 4.5.3. Pong
The Pong message contains an opcode of 0x03. The Pong message contains an opcode of 0x03.
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 of the Ping and Pong MUST be the same.
4.5. Data Frames 4.6. Data Frames
All frame types not listed in Section 4.4 are data frames, which All frame types not listed in Section 4.5 are data frames, which
transport application-layer data. The opcode determines the transport application-layer data. The opcode determines the
interpretation of 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.
4.6. Examples 4.7. 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
* 0x84 0x03 "Hel" * 0x84 0x03 "Hel"
skipping to change at page 25, line 16 skipping to change at page 24, line 16
* 0x03 0x05 "Hello" * 0x03 0x05 "Hello"
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.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 0x6 through 0xF, the extension data
field, and the frame-rsv1, frame-rsv2, frame-rsv3, and frame-rsv4 field, and the frame-rsv1, frame-rsv2, frame-rsv3, and frame-rsv4
bits of the frame header for use by extensions. Below are some bits of the frame header for use by extensions. Below are some
anticipated uses of extensions. This list is neither complete nor anticipated uses of extensions. This list is neither complete nor
proscriptive. proscriptive.
skipping to change at page 26, line 16 skipping to change at page 25, line 16
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* to a
host /host/, on a port /port/, from an origin whose ASCII WebSocket URL /url/, it must meet the following requirements. In the
serialization is /origin/, with a flag /secure/, with a string giving following text, we will use terms from Section 3 such as "/host/" and
a /resource name/, with a (possibly empty) list of strings giving the "/secure/ flag" as defined in that section.
/protocols/, and optionally with a /defer cookies/ flag, it must run
the following steps. [ORIGIN]
1. Verify that the WebSocket URL and its components are valid
according to Section 3.3. If any of the requirements are not
met, the client MUST fail the WebSocket connection and abort
these steps.
2. If the user agent already has a WebSocket connection to the 1. The WebSocket URL and its components MUST be valid according to
remote host (IP address) identified by /host/, even if known by Section 3.3. If any of the requirements are not met, the client
another name, wait until that connection has been established or MUST fail the WebSocket connection and abort these steps.
for that connection to have failed. If multiple connections to
the same IP address are attempted simultaneously, the user agent
must serialize them so that there is no more than one connection
at a time running through the following steps.
If the user agent cannot determine the IP address of the remote 2. If the user agent already has a WebSocket connection to the
host (for example because all communication is being done remote host (IP address) identified by /host/, even if known by
through a proxy server that performs DNS queries itself), then another name, the user agent MUST wait until that connection has
the user agent must assume for the purposes of this step that been established or for that connection to have failed. If
each host name refers to a distinct remote host, but should multiple connections to the same IP address are attempted
instead limit the total number of simultaneous connections that simultaneously, the user agent MUST serialize them so that there
are not established to a reasonably low number (e.g., in a Web is no more than one connection at a time running through the
browser, to the number of tabs the user has open). following steps.
NOTE: This makes it harder for a script to perform a denial of If the user agent cannot determine the IP address of the remote
service attack by just opening a large number of WebSocket host (for example because all communication is being done through
connections to a remote host. A server can further reduce the a proxy server that performs DNS queries itself), then the user
load on itself when attacked by making use of this by pausing agent MUST assume for the purposes of this step that each host
before closing the connection, as that will reduce the rate at name refers to a distinct remote host, but should instead limit
which the client reconnects. the total number of simultaneous connections that are not
established to a reasonably low number (e.g., in a Web browser,
to the number of tabs the user has open).
NOTE: There is no limit to the number of established WebSocket NOTE: This makes it harder for a script to perform a denial of
connections a user agent can have with a single remote host. service attack by just opening a large number of WebSocket
connections to a remote host. A server can further reduce the
load on itself when attacked by making use of this by pausing
before closing the connection, as that will reduce the rate at
which the client reconnects.
Servers can refuse to connect users with an excessive number of NOTE: There is no limit to the number of established WebSocket
connections, or disconnect resource-hogging users when suffering connections a user agent can have with a single remote host.
high load. Servers can refuse to connect users with an excessive number of
connections, or disconnect resource-hogging users when suffering
high load.
3. _Connect_: If the user agent is configured to use a proxy when 3. _Proxy Usage_: If the user agent is configured to use a proxy
using the WebSocket protocol to connect to host /host/ and/or when using the WebSocket protocol to connect to host /host/
port /port/, then connect to that proxy and ask it to open a TCP and/or port /port/, then the user agent SHOULD connect to that
connection to the host given by /host/ and the port given by proxy and ask it to open a TCP connection to the host given by
/port/. /host/ and the port given by /port/.
EXAMPLE: For example, if the user agent uses an HTTP proxy EXAMPLE: For example, if the user agent uses an HTTP proxy for
for all traffic, then if it was to try to connect to port 80 all traffic, then if it was to try to connect to port 80 on
on server example.com, it might send the following lines to server example.com, it might send the following lines to the
the proxy server: proxy server:
CONNECT example.com:80 HTTP/1.1 CONNECT example.com:80 HTTP/1.1
Host: example.com Host: example.com
If there was a password, the connection might look like: If there was a password, the connection might look like:
CONNECT example.com:80 HTTP/1.1 CONNECT example.com:80 HTTP/1.1
Host: example.com Host: example.com
Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE= Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE=
Otherwise, if the user agent is not configured to use a proxy, If the user agent is not configured to use a proxy, then a direct
then open a TCP connection to the host given by /host/ and the TCP connection SHOULD be opened to the host given by /host/ and
port given by /port/. the port given by /port/.
NOTE: Implementations that do not expose explicit UI for
selecting a proxy for WebSocket connections separate from other
proxies are encouraged to use a SOCKS proxy for WebSocket
connections, if available, or failing that, to prefer the proxy
configured for HTTPS connections over the proxy configured for
HTTP connections.
For the purpose of proxy autoconfiguration scripts, the URL to
pass the function must be constructed from /host/, /port/,
/resource name/, and the /secure/ flag using the steps to
construct a WebSocket URL.
NOTE: The WebSocket protocol can be identified in proxy
autoconfiguration scripts from the scheme ("ws:" for unencrypted
connections and "wss:" for encrypted connections).
4. If the connection could not be opened, then fail the WebSocket
connection and abort these steps.
5. If /secure/ is true, perform a TLS handshake over the
connection. If this fails (e.g. the server's certificate could
not be verified), then fail the WebSocket connection and abort
these steps. Otherwise, all further communication on this
channel must run through the encrypted tunnel. [RFC2246]
User agents must use the Server Name Indication extension in the
TLS handshake. [RFC4366]
6. Send the UTF-8 string "GET" followed by a UTF-8-encoded U+0020
SPACE character to the remote side (the server).
Send the /resource name/ value, encoded as UTF-8.
Send another UTF-8-encoded U+0020 SPACE character, followed by
the UTF-8 string "HTTP/1.1", followed by a UTF-8-encoded U+000D
CARRIAGE RETURN U+000A LINE FEED character pair (CRLF).
7. Let /fields/ be an empty list of strings.
8. Add the string "Upgrade: WebSocket" to /fields/.
9. Add the string "Connection: Upgrade" to /fields/.
10. Let /hostport/ be an empty string.
11. Append the /host/ value, converted to ASCII lowercase, to
/hostport/.
12. If /secure/ is false, and /port/ is not 80, or if /secure/ is
true, and /port/ is not 443, then append a U+003A COLON
character (:) followed by the value of /port/, expressed as a
base-ten integer, to /hostport/.
13. Add the string consisting of the concatenation of the string
"Host:", a U+0020 SPACE character, and /hostport/, to /fields/.
14. Add the string consisting of the concatenation of the string
"Origin:", a U+0020 SPACE character, and the /origin/ value, to
/fields/.
15. Add the string "Sec-WebSocket-Draft: 2" to /fields/.
16. If there is no /protocols/, then skip this step.
Otherwise, generate the acceptable protocol string by joining
each protocol in /protocols/ using a U+0020 SPACE character.
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
resource accessed over HTTP, if /secure/ is false, or HTTPS, if
it is true, on host /host/, port /port/, with /resource name/ as
the path (and possibly query parameters), then add to /fields/
any HTTP headers that would be appropriate for that information.
[RFC2616] [RFC2109] [RFC2965]
This includes "HttpOnly" cookies (cookies with the http-only-
flag set to true); the WebSocket protocol is not considered a
non-HTTP API for the purpose of cookie processing.
18. When one or more HTTP headers are to be added to /fields/ for
this step, each header must be added separately, and each header
must be added as one entry consisting of the header's name in
its canonical case, followed by a U+003A COLON character (:) and
a U+0020 SPACE character, followed by the value with no use of
continuation lines (e.g. containing no U+000A LINE FEED
characters.)
19. Let /spaces_1/ be a random integer from 1 to 12 inclusive.
Let /spaces_2/ be a random integer from 1 to 12 inclusive.
EXAMPLE: For example, 5 and 9.
20. Let /max_1/ be the largest integer not greater than
4,294,967,295 divided by /spaces_1/.
Let /max_2/ be the largest integer not greater than
4,294,967,295 divided by /spaces_2/.
EXAMPLE: Continuing the example, 858,993,459 and 477,218,588.
21. Let /number_1/ be a random integer from 0 to /max_1/ inclusive.
Let /number_2/ be a random integer from 0 to /max_2/ inclusive.
EXAMPLE: For example, 777,007,543 and 114,997,259.
22. Let /product_1/ be the result of multiplying /number_1/ and
/spaces_1/ together.
Let /product_2/ be the result of multiplying /number_2/ and
/spaces_2/ together.
EXAMPLE: Continuing the example, 3,885,037,715 and
1,034,975,331.
23. Let /key_1/ be a string consisting of /product_1/, expressed in
base ten using the numerals in the range U+0030 DIGIT ZERO (0)
to U+0039 DIGIT NINE (9).
Let /key_2/ be a string consisting of /product_2/, expressed in
base ten using the numerals in the range U+0030 DIGIT ZERO (0)
to U+0039 DIGIT NINE (9).
EXAMPLE: Continuing the example, "3885037715" and "1034975331".
24. Insert between one and twelve random characters from the ranges
U+0021 to U+002F and U+003A to U+007E into /key_1/ at random
positions.
Insert between one and twelve random characters from the ranges
U+0021 to U+002F and U+003A to U+007E into /key_2/ at random
positions.
NOTE: This corresponds to random printable ASCII characters
other than the digits and the U+0020 SPACE character.
EXAMPLE: Continuing the example, this could lead to "P388O503D&
ul7{K%gX(%715" and "1N?|kUT0or3o4I97N5-S3O31".
25. Insert /spaces_1/ U+0020 SPACE characters into /key_1/ at random
positions other than the start or end of the string.
Insert /spaces_2/ U+0020 SPACE characters into /key_2/ at random
positions other than the start or end of the string.
EXAMPLE: Continuing the example, this could lead to "P388 O503D&
ul7 {K%gX( %7 15" and "1 N ?|k UT0or 3o 4 I97N 5-S3O 31".
26. Add the string consisting of the concatenation of the string
"Sec-WebSocket-Key1:", a U+0020 SPACE character, and the /key_1/
value, to /fields/.
Add the string consisting of the concatenation of the string
"Sec-WebSocket-Key2:", a U+0020 SPACE character, and the /key_2/
value, to /fields/.
27. For each string in /fields/, in a random order: send the string,
encoded as UTF-8, followed by a UTF-8-encoded U+000D CARRIAGE
RETURN U+000A LINE FEED character pair (CRLF). It is important
that the fields be output in a random order so that servers not
depend on the particular order used by any particular client.
28. Send a UTF-8-encoded U+000D CARRIAGE RETURN U+000A LINE FEED
character pair (CRLF).
29. Let /key_3/ be a string consisting of eight random bytes (or
equivalently, a random 64 bit unsigned integer encoded in big-
endian order).
EXAMPLE: For example, 0x47 0x30 0x22 0x2D 0x5A 0x3F 0x47 0x58.
30. Send /key_3/ to the server.
31. Read bytes from the server until either the connection closes,
or a 0x0A byte is read. Let /field/ be these bytes, including
the 0x0A byte.
If /field/ is not at least seven bytes long, or if the last two
bytes aren't 0x0D and 0x0A respectively, or if /field/ contains
any 0x0D bytes other than the penultimate byte, or if /field/
does not contain at least two 0x20 bytes, then _fail the
WebSocket connection_ and abort these steps.
User agents may apply a timeout to this step, failing the
WebSocket connection if the server does not send back data in a
suitable time period.
32. Let /code/ be the substring of /field/ that starts from the byte
after the first 0x20 byte, and ends with the byte before the
second 0x20 byte.
33. If /code/, interpreted as UTF-8, is "101", then move to the next
step.
If /code/, interpreted as UTF-8, is "407", then either close the
connection and jump back to step 2, providing appropriate
authentication information, or fail the WebSocket connection.
407 is the code used by HTTP meaning "Proxy Authentication
Required". User agents that support proxy authentication must
interpret the response as defined by HTTP (e.g. to find and
interpret the |Proxy-Authenticate| header).
Otherwise, fail the WebSocket connection and abort these steps.
34. Let /fields/ be a list of name-value pairs, initially empty.
35. _Field_: Let /name/ and /value/ be empty byte arrays.
36. Read a byte from the server.
If the connection closes before this byte is received, then fail
the WebSocket connection and abort these steps.
Otherwise, handle the byte as described in the appropriate entry
below:
-> If the byte is 0x0D (UTF-8 CR)
If the /name/ byte array is empty, then jump to the fields
processing step. Otherwise, fail the WebSocket connection
and abort these steps.
-> If the byte is 0x0A (UTF-8 LF)
Fail the WebSocket connection and abort these steps.
-> If the byte is 0x3A (UTF-8 :)
Move on to the next step.
-> If the byte is in the range 0x41 to 0x5A (UTF-8 A-Z)
Append a byte whose value is the byte's value plus 0x20 to
the /name/ byte array and redo this step for the next byte.
-> Otherwise
Append the byte to the /name/ byte array and redo this step
for the next byte.
NOTE: This reads a field name, terminated by a colon, converting
upper-case letters in the range A-Z to lowercase, and aborting
if a stray CR or LF is found.
37. Let /count/ equal 0.
NOTE: This is used in the next step to skip past a space
character after the colon, if necessary.
38. Read a byte from the server and increment /count/ by 1.
If the connection closes before this byte is received, then fail
the WebSocket connection and abort these steps.
Otherwise, handle the byte as described in the appropriate entry
below:
-> If the byte is 0x20 (UTF-8 space) and /count/ equals 1
Ignore the byte and redo this step for the next byte.
-> If the byte is 0x0D (UTF-8 CR)
Move on to the next step.
-> If the byte is 0x0A (UTF-8 LF)
Fail the WebSocket connection and abort these steps.
-> Otherwise
Append the byte to the /value/ byte array and redo this step
for the next byte.
NOTE: This reads a field value, terminated by a CRLF, skipping
past a single space after the colon if there is one.
39. Read a byte from the server.
If the connection closes before this byte is received, or if the
byte is not a 0x0A byte (UTF-8 LF), then fail the WebSocket
connection and abort these steps.
NOTE: This skips past the LF byte of the CRLF after the field. NOTE: Implementations that do not expose explicit UI for
selecting a proxy for WebSocket connections separate from other
proxies are encouraged to use a SOCKS proxy for WebSocket
connections, if available, or failing that, to prefer the proxy
configured for HTTPS connections over the proxy configured for
HTTP connections.
40. Append an entry to the /fields/ list that has the name given by For the purpose of proxy autoconfiguration scripts, the URL to
the string obtained by interpreting the /name/ byte array as a pass the function must be constructed from /host/, /port/,
UTF-8 byte stream and the value given by the string obtained by /resource name/, and the /secure/ flag using the steps to
interpreting the /value/ byte array as a UTF-8 byte stream. construct a WebSocket URL.
41. Return to the "Field" step above. NOTE: The WebSocket protocol can be identified in proxy
autoconfiguration scripts from the scheme ("ws:" for unencrypted
connections and "wss:" for encrypted connections).
42. _Fields processing_: Read a byte from the server. 4. If the connection could not be opened, either because a direct
connection failed or because any proxy used returned an error,
then the user agent MUST fail the WebSocket connection and abort
the connection attempt.
If the connection closes before this byte is received, or if the 5. If /secure/ is true, the user agent MUST perform a TLS handshake
byte is not a 0x0A byte (UTF-8 LF), then fail the WebSocket over the connection. If this fails (e.g. the server's
connection and abort these steps. certificate could not be verified), then the user agent MUST fail
the WebSocket connection and abort the connection. Otherwise,
all further communication on this channel MUST run through the
encrypted tunnel. [RFC2246]
NOTE: This skips past the LF byte of the CRLF after the blank User agents MUST use the Server Name Indication extension in the
line after the fields. TLS handshake. [RFC4366]
43. Let the /list of cookies/ be empty. Once a connection to the server has been established (including a
connection via a proxy or over a TLS-encrypted tunnel), the client
MUST send a handshake to the server. The handshake consists of an
HTTP upgrade request, along with a list of required and optional
headers. The requirements for this handshake are as follows.
44. If there is not exactly one entry in the /fields/ list whose 1. The handshake must be a valid HTTP request as specified by
name is "upgrade", or if there is not exactly one entry in the [RFC2616].
/fields/ list whose name is "connection", or if there is not
exactly one entry in the /fields/ list whose name is "sec-
websocket-origin", or if there is not exactly one entry in the
/fields/ list whose name is "sec-websocket-location", or if the
/protocol/ was specified but there is not exactly one entry in
the /fields/ list whose name is "sec-websocket-protocol", or if
there are any entries in the /fields/ list whose names are the
empty string, then fail the WebSocket connection and abort these
steps. Otherwise, handle each entry in the /fields/ list as
follows:
-> If the entry's name is "upgrade" 2. The Method of the request MUST be GET and the HTTP version MUST
If the value, converted to ASCII lowercase, is not exactly be at least 1.1.
equal to the string "websocket", then fail the WebSocket
connection and abort these steps.
-> If the entry's name is "connection" For example, if the WebSocket URL is "ws://example.com/chat",
If the value, converted to ASCII lowercase, is not exactly The first line sent SHOULD be "GET /chat HTTP/1.1"
equal to the string "upgrade", then fail the WebSocket
connection and abort these steps.
-> If the entry's name is "sec-websocket-origin" 3. The request must contain a "Request-URI" as part of the GET
If the value is not exactly equal to /origin/, then fail the method. This MUST match the /resource name/ Section 3.
WebSocket connection and abort these steps. [ORIGIN]
-> If the entry's name is "sec-websocket-location" 4. The request MUST contain a "Host" header whose value is equal to
If the value is not exactly equal to a string obtained from the authority component of the WebSocket URL.
the steps to construct a WebSocket URL from /host/, /port/,
/resource name/, and the /secure/ flag, then fail the
WebSocket connection and abort these steps.
-> If the entry's name is "sec-websocket-protocol" 5. The request MUST contain an "Upgrade" header whose value is
If there was a /protocols/ string specified, and the value is equal to "websocket".
not exactly equal to one of the items in /protocols/, then
fail the WebSocket connection and abort these steps. (If no
/protocols/ was specified, the field is ignored.)
-> If the entry's name is "set-cookie" or "set-cookie2" or 6. The request MUST contain a "Connection" header whose value is
another cookie-related field name equal to "Upgrade".
If the relevant specification is supported by the user agent,
add the cookie, interpreted as defined by the appropriate
specification, to the /list of cookies/, with the resource
being the one with the host /host/, the port /port/, the path
(and possibly query parameters) /resource name/, and the
scheme |http| if /secure/ is false and |https| if /secure/ is
true. [RFC2109] [RFC2965]
If the relevant specification is not supported by the user 7. The request MUST include a header with the name "Sec-WebSocket-
agent, then the field must be ignored. Key". The value of this header MUST be a nonce consisting of a
randomly selected 16-byte value that has been base64-encoded
[RFC3548]. The nonce MUST be randomly selected randomly for
each connection.
The cookies added to the /list of cookies/ are discarded if NOTE: As an example, if the randomly selected value was the
the connection fails to be established. Only if and when the sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09
connection is established do the cookies actually get 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the header
applied. would be "AQIDBAUGBwgJCgsMDQ4PEC=="
-> Any other name 8. The request MUST include a header with the name "Sec-WebSocket-
Ignore it. Origin". The value of this header MUST be the ASCII
serialization of origin of the context in which the code
establishing the connection is running [I-D.ietf-websec-origin].
45. Let /challenge/ be the concatenation of /number_1/, expressed as As an example, if code is running on www.example.com attempting
a big-endian 32 bit integer, /number_2/, expressed as a big- to establish a connection to ww2.example.com, the value of the
endian 32 bit integer, and the eight bytes of /key_3/ in the header would be "http://www.example.com".
order they were sent on the wire.
EXAMPLE: Using the examples given earlier, this leads to the 16 9. The request MUST include a header with the name "Sec-WebSocket-
bytes 0x2E 0x50 0x31 0xB7 0x06 0xDA 0xB8 0x0B 0x47 0x30 0x22 Version". The value of this header must be 4.
0x2D 0x5A 0x3F 0x47 0x58.
46. Let /expected/ be the MD5 fingerprint of /challenge/ as a big- 10. The request MAY include a header with the name "Sec-WebSocket-
endian 128 bit string. [RFC1321] Protocol". If present, this value indicates the subprotocol(s)
the client wishes to speak. The ABNF for the value of this
header is 1#(token | quoted-string), where the definitions of
/token/ and /quoted-string/ are as given in [RFC2616].
EXAMPLE: Using the examples given earlier, this leads to the 16 11. The request MAY include a header with the name "Sec-WebSocket-
bytes 0x30 0x73 0x74 0x33 0x52 0x6C 0x26 0x71 0x2D 0x32 0x5A Extensions". If present, this value indicates the protocol-
0x55 0x5E 0x77 0x65 0x75. In UTF-8, these bytes correspond to level extension(s) the client wishes to speak. The ABNF for the
the string "0st3Rl&q-2ZU^weu". value of this header is 1#(token | quoted-string), where the
definitions of /token/ and /quoted-string/ are as given in
[RFC2616].
47. Read sixteen bytes from the server. Let /reply/ be those bytes. 12. The request MAY include headers associated with sending cookies,
as defined by the appropriate specifications
[I-D.ietf-httpstate-cookie].
If the connection closes before these bytes are received, then Once the client's opening handshake has been sent, the client MUST
fail the WebSocket connection and abort these steps. wait for a response from the server before sending any further data.
The client MUST validate the server's response as follows:
48. If /reply/ does not exactly equal /expected/, then fail the o If the status code received from the server is not 101, the client
WebSocket connection and abort these steps. MUST fail the WebSocket connection.
49. If the /defer cookies/ flag is not set, apply the cookies in the o If the response lacks an Upgrade header or the Upgrade header
/list of cookies/. contains a value that is not an ASCII case-insensitive match for
the value "websocket", the client MUST fail the WebSocket
connection.
50. The *WebSocket connection is established*. Now the user agent o If the response lacks a Connection header or the Connection header
must send and receive to and from the connection as described in contains a value that is not an ASCII case-insensitive match for
the next section. the value "Upgrade", the client MUST fail the WebSocket
connection.
51. If the /defer cookies/ flag is set, store the /list of cookies/ o If the response lacks a Sec-WebSocket-Accept header or the Sec-
for use by the component that invoked this algorithm. WebSocket-Accept contains a value other than the base64-encoded
SHA-1 of the concatenation of the Sec-WebSocket-Key with the
string "258EAFA5-E914-47DA-95CA-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 subtlely different ways user agents to implement the algorithm in subtly different ways that
that are equivalent in all ways except that they terminate the are equivalent in all ways except that they terminate the connection
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.
When the user agent is to "apply the cookies" in a /list of cookies/,
it must handle each cookie in the /list of cookies/ as defined by the
appropriate specification. [RFC2109] [RFC2965]
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.
skipping to change at page 36, line 44 skipping to change at page 30, line 5
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 should abort handshake that matches the description below, the server must abort
the WebSocket connection. the WebSocket connection.
1. The three-character UTF-8 string "GET". 1. An HTTP/1.1 or higher GET request, including a "Request-URI"
[RFC2616] that should be interpreted as a /resource name/
2. A UTF-8-encoded U+0020 SPACE character (0x20 byte). Section 3.
3. A string consisting of all the bytes up to the next UTF-8-encoded
U+0020 SPACE character (0x20 byte). The result of decoding this
string as a UTF-8 string is the name of the resource requested by
the server. If the server only supports one resource, then this
can safely be ignored; the client verifies that the right
resource is supported based on the information included in the
server's own handshake. The resource name will begin with U+002F
SOLIDUS character (/) and will only include characters in the
range U+0021 to U+007E.
4. A string of bytes terminated by a UTF-8-encoded U+000D CARRIAGE
RETURN U+000A LINE FEED character pair (CRLF). All the
characters from the second 0x20 byte up to the first 0x0D 0x0A
byte pair in the data from the client can be safely ignored. (It
will probably be the string "HTTP/1.1".)
5. A series of fields.
Each field is terminated by a UTF-8-encoded U+000D CARRIAGE
RETURN U+000A LINE FEED character pair (CRLF). The end of the
fields is denoted by the terminating CRLF pair being followed
immediately by another CRLF pair.
NOTE: In other words, the fields start with the first 0x0D 0x0A
byte pair, end with the first 0x0D 0x0A 0x0D 0x0A byte sequence,
and are separate from each other by 0x0D 0x0A byte pairs.
The fields are encoded as UTF-8.
Each field consists of a name, consisting of one or more
characters in the ranges U+0021 to U+0039 and U+003B to U+007E,
followed by a U+003A COLON character (:) and a U+0020 SPACE
character, followed by zero or more characters forming the value.
The expected field names, the meaning of their corresponding
values, and the processing servers are required to apply to those
fields, are described below, after the description of the client
handshake.
6. After the first 0x0D 0x0A 0x0D 0x0A byte sequence, indicating the
end of the fields, the client sends eight random bytes. These
are used in constructing the server handshake.
The expected field names, and the meaning of their corresponding
values, are as follows. Field names must be compared in an ASCII
case-insensitive manner.
|Upgrade|
Invariant part of the handshake. Will always have a value that is
an ASCII case-insensitive match for the string "WebSocket".
Can be safely ignored, though the server should abort the
WebSocket connection if this field is absent or has a different
value, to avoid vulnerability to cross-protocol attacks.
|Connection|
Invariant part of the handshake. Will always have a value that is
an ASCII case-insensitive match for the string "Upgrade".
Can be safely ignored, though the server should abort the
WebSocket connection if this field is absent or has a different
value, to avoid vulnerability to cross-protocol attacks.
|Host|
The value gives the hostname that the client intended to use when
opening the WebSocket. It would be of interest in particular to
virtual hosting environments, where one server might serve
multiple hosts, and might therefore want to return different data.
Can be safely ignored, though the server should abort the
WebSocket connection if this field is absent or has a value that
does not match the server's host name, to avoid vulnerability to
cross-protocol attacks and DNS rebinding attacks.
|Origin|
The value gives the scheme, hostname, and port (if it's not the
default port for the given scheme) of the page that asked the
client to open the WebSocket. It would be interesting if the
server's operator had deals with operators of other sites, since
the server could then decide how to respond (or indeed, _whether_
to respond) based on which site was requesting a connection.
[ORIGIN]
Can be safely ignored, though the server should abort the
WebSocket connection if this field is absent or has a value that
does not match one of the origins the server is expecting to
communicate with, to avoid vulnerability to cross-protocol attacks
and cross-site scripting attacks.
|Sec-WebSocket-Protocol| 2. A "Host" header containing the server's authority.
The value gives the name of a subprotocol that the client is
intending to select. It would be interesting if the server
supports multiple protocols or protocol versions.
Can be safely ignored, though the server may abort the WebSocket 3. A "Sec-WebSocket-Key" header with a base64-encoded value that,
connection if the field is absent but the conventions for when decoded, is 16 bytes in length.
communicating with the server are such that the field is expected;
and the server should abort the WebSocket connection if the field
has a value that does not match one of the subprotocols that the
server supports, to avoid integrity errors once the connection is
established.
|Sec-WebSocket-Key1| 4. A "Sec-WebSocket-Origin" header.
|Sec-WebSocket-Key2| 5. A "Sec-WebSocket-Version" header, with a value of 4.
The values provide the information required for computing the
server's handshake, as described in the next section.
|Sec-WebSocket-Draft| 6. Optionally, a "Sec-WebSocket-Protocol header, with a list of
The value provides the version of this draft protocol that the values indicating which protocols the client would like to speak,
client is attempting to establish a connection using. If this ordered by preference.
value is not equal to a version of the draft protocol that the
server understands, the server MUST abort the WebSocket
connection.
Other fields 7. Optionally, a "Sec-WebSocket-Extensions" header, with a list of
Other fields can be used, such as "Cookie", for authentication values indicating which extensions the client would like to
purposes. Their semantics are equivalent to the semantics of the speak.
HTTP headers with the same names.
Unrecognized fields can be safely ignored, and are probably either 8. Optionally, other headers, such as those used to send cookies to
the result of intermediaries injecting fields unrelated to the a server. Unknown headers MUST be ignored.
operation of the WebSocket protocol, or clients that support future
versions of the protocol offering options that the server doesn't
support.
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 run the following steps. server must complete the following steps to accept the connection and
send the server's opening handshake.
1. If the server supports encryption, perform a TLS handshake over
the connection. If this fails (e.g. the client indicated a host
name in the extended client hello "server_name" extension that
the server does not host), then close the connection; otherwise,
all further communication for the connection (including the
server handshake) must run through the encrypted tunnel.
[RFC2246]
2. Establish the following information:
/host/
The host name or IP address of the WebSocket server, as it is
to be addressed by clients. The host name must be punycode-
encoded if necessary. If the server can respond to requests
to multiple hosts (e.g. in a virtual hosting environment),
then the value should be derived from the client's handshake,
specifically from the "Host" field. The /host/ value must be
lowercase (not containing characters in the range U+0041
LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z).
/port/
The port number on which the server expected and/or received
the connection.
/resource name/
An identifier for the service provided by the server. If the
server provides multiple services, then the value should be
derived from the resource name given in the client's
handshake.
/secure flag/
True if the connection is encrypted or if the server expected
it to be encrypted; false otherwise.
/origin/
The ASCII serialization of the origin that the server is
willing to communicate with, converted to ASCII lowercase.
If the server can respond to requests from multiple origins
(or indeed, all origins), then the value should be derived
from the client's handshake, specifically from the "Origin"
field. [ORIGIN]
/subprotocol/
Either null, or a string representing the subprotocol the
server is ready to use. If the server supports multiple
subprotocols, then the value should be derived from the
client's handshake, specifically by selecting one of the
values from the "Sec-WebSocket-Protocol" field. 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 purposes.
/key_1/
The value of the "Sec-WebSocket-Key1" field in the client's
handshake.
/key_2/
The value of the "Sec-WebSocket-Key2" field in the client's
handshake.
/key_3/
The eight random bytes sent after the first 0x0D 0x0A 0x0D
0x0A sequence in the client's handshake.
3. Let /location/ be the string that results from constructing a
WebSocket URL from /host/, /port/, /resource name/, and /secure
flag/.
4. Let /key-number_1/ be the digits (characters in the range U+0030
DIGIT ZERO (0) to U+0039 DIGIT NINE (9)) in /key_1/, interpreted
as a base ten integer, ignoring all other characters in /key_1/.
Let /key-number_2/ be the digits (characters in the range U+0030
DIGIT ZERO (0) to U+0039 DIGIT NINE (9)) in /key_2/, interpreted
as a base ten integer, ignoring all other characters in /key_2/.
EXAMPLE: For example, assume that the client handshake was:
GET / HTTP/1.1
Connection: Upgrade
Host: example.com
Upgrade: WebSocket
Sec-WebSocket-Key1: 3e6b263 4 17 80
Origin: http://example.com
Sec-WebSocket-Key2: 17 9 G`ZD9 2 2b 7X 3 /r90
WjN}|M(6
The /key-number_1/ would be the number 3,626,341,780, and the
/key-number_2/ would be the number 1,799,227,390.
In this example, incidentally, /key_3/ is "WjN}|M(6", or 0x57
0x6A 0x4E 0x7D 0x7C 0x4D 0x28 0x36.
5. Let /spaces_1/ be the number of U+0020 SPACE characters in
/key_1/.
Let /spaces_2/ be the number of U+0020 SPACE characters in
/key_2/.
If either /spaces_1/ or /spaces_2/ is zero, then abort the
WebSocket connection. This is a symptom of a cross-protocol
attack.
EXAMPLE: In the example above, /spaces_1/ would be 4 and
/spaces_2/ would be 10.
6. If /key-number_1/ is not an integral multiple of /spaces_1/,
then abort the WebSocket connection.
If /key-number_2/ is not an integral multiple of /spaces_2/,
then abort the WebSocket connection.
NOTE: This can only happen if the client is not a conforming
WebSocket client.
7. Let /part_1/ be /key-number_1/ divided by /spaces_1/.
Let /part_2/ be /key-number_2/ divided by /spaces_2/.
EXAMPLE: In the example above, /part_1/ would be 906,585,445 and
/part_2/ would be 179,922,739.
8. Let /challenge/ be the concatenation of /part_1/, expressed as a
big-endian 32 bit integer, /part_2/, expressed as a big-endian
32 bit integer, and the eight bytes of /key_3/ in the order they
were sent on the wire.
EXAMPLE: In the example above, this would be the 16 bytes 0x36 1. If the server supports encryption, perform a TLS handshake over
0x09 0x65 0x65 0x0A 0xB9 0x67 0x33 0x57 0x6A 0x4E 0x7D 0x7C 0x4D the connection. If this fails (e.g. the client indicated a host
0x28 0x36. name in the extended client hello "server_name" extension that
the server does not host), then close the connection; otherwise,
all further communication for the connection (including the
server handshake) must run through the encrypted tunnel.
[RFC2246]
9. Let /response/ be the MD5 fingerprint of /challenge/ as a big- 2. Establish the following information:
endian 128 bit string. [RFC1321]
EXAMPLE: In the example above, this would be the 16 bytes 0x6E /origin/
0x60 0x39 0x65 0x42 0x6B 0x39 0x7A 0x24 0x52 0x38 0x70 0x4F 0x74 The |Sec-WebSocket-Origin| header in the client's handshake
0x56 0x62, or "n`9eBk9z$R8pOtVb" in UTF-8. indicates the origin of the script establishing the
connection. The origin is serialized to ASCII and converted
to lowercase. The server MAY use this information as part of
a determination of whether to accept the incoming connection.
10. Send the following line, terminated by the two characters U+000D /key/
CARRIAGE RETURN and U+000A LINE FEED (CRLF) and encoded as The |Sec-WebSocket-Key| header in the client's handshake
UTF-8, to the client: includes a base64-encoded value that, if decoded, is 16 bytes
in length. This (encoded) value is used in the creation of
the server's handshake to indicate an acceptance of the
connection. It is not necessary for the server to base64-
decode the Sec-WebSocket-Key value.
HTTP/1.1 101 WebSocket Protocol Handshake /version/
The |Sec-WebSocket-Version| header in the client's handshake
includes the version of the WebSocket protocol the client is
attempting to communicate with. If this version does not
match a version understood by the server, the server MUST
abort the WebSocket connection. The server MAY send a non-200
response code with a |Sec-WebSocket-Version| header indicating
the version(s) the server is capable of understanding along
with this non-200 response code.
This line may be sent differently if necessary, but must match /resource name/
the Status-Line production defined in the HTTP specification, An identifier for the service provided by the server. If the
with the Status-Code having the value 101. server provides multiple services, then the value should be
derived from the resource name given in the client's handshake
from the Request-URI [RFC2616] of the GET method.
11. Send the following fields to the client. Each field must be /subprotocol/
sent as a line consisting of the field name, which must be an A (possibly empty) list representing the subprotocol the
ASCII case-insensitive match for the field name in the list server is ready to use. If the server supports multiple
below, followed by a U+003A COLON character (:) and a U+0020 subprotocols, then the value should be derived from the
SPACE character, followed by the field value as specified in the client's handshake, specifically by selecting one of the
list below, followed by the two characters U+000D CARRIAGE values from the "Sec-WebSocket-Protocol" field. The absence
RETURN and U+000A LINE FEED (CRLF). The lines must be encoded of such a field is equivalent to the null value. The empty
as UTF-8. The lines may be sent in any order. string is not the same as the null value for these purposes.
|Upgrade| /extensions/
The value must be the string "WebSocket". A (possibly empty) list representing the protocol-level
extensions the server is ready to use. If the server supports
multiple extensions, then the value should be derived from the
client's handshake, specifically by selecting one of the
values from the "Sec-WebSocket-Extensions" field. 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 purposes.
|Connection| 3. If the server chooses to accept the incoming connection, it must
The value must be the string "Upgrade". reply with a valid HTTP response indicating the following.
|Sec-WebSocket-Location| 1. A 101 response code. Such a response could look like
The value must be /location/ "HTTP/1.1 101 Switching Protocols"
|Sec-WebSocket-Origin| 2. A "Sec-WebSocket-Accept" header. The value of this header is
The value must be /origin/ constructed by concatenating the value of the client's "Sec-
WebSocket-Key" header in the client's handshake with the
string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", taking the
SHA-1 hash of this concatenated value to obtain a 20-byte
value, and base64-encoding this 20-byte hash.
|Sec-WebSocket-Protocol| NOTE: As an example, if the value of the "Sec-WebSocket-Key"
This field must be included if /subprotocol/ is not null, and header in the client's handshake were
must not be included if /subprotocol/ is null. "dGhlIHNhbXBsZSBub25jZQ==", the server would append the
string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" to form the
string "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-
C5AB0DC85B11". The server would then take the SHA-1 hash of
this string, 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 then base64-encoded, to give the
value "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", which would be returned
in the "Sec-WebSocket-Accept" header.
If included, the value must be /subprotocol/ 3. A "Sec-WebSocket-Nonce" header. The value of this header
MUST be a nonce consisting of a randomly selected 16-byte
value that has been base64-encoded [RFC3548]. The nonce MUST
be randomly selected randomly for each connection.
Optionally, include "Set-Cookie", "Set-Cookie2", or other NOTE: As an example, if the randomly selected value was the
cookie-related fields, with values equal to the values that sequence of bytes 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
would be used for the identically named HTTP headers. [RFC2109] 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f 0x10, the value of the
[RFC2965] header would be "AQIDBAUGBwgJCgsMDQ4PEC==" value
12. Send two bytes 0x0D 0x0A (UTF-8 CRLF). 4. Optionally, a "Sec-WebSocket-Protocol" header, indicating the
subprotocol, if any, the server is prepared to speak. The
value of this header must be equal to one of the values
specified by the client in its opening handshake.
13. Send /response/. 5. Optionally, a "Sec-WebSocket-Extensions" header, indicating
the protocol level extensions, if any, the server is prepared
to speak. The value of this header must be a subset of the
values specified by the client in its opening handshake.
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, as
described in the next section. 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
skipping to change at page 51, line 38 skipping to change at page 40, line 38
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.
10.4. Sec-WebSocket-Key1 and Sec-WebSocket-Key2 10.4. Sec-WebSocket-Key and Sec-WebSocket-Nonce
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-Key
Applicable protocol Applicable protocol
http http
Status Status
reserved; do not use outside WebSocket handshake reserved; do not use outside WebSocket handshake
Author/Change controller Author/Change controller
IETF IETF
Specification document(s) Specification document(s)
This document is the relevant specification. This document is the relevant specification.
Related information Related information
None. None.
Header field name Header field name
Sec-WebSocket-Key2 Sec-WebSocket-Nonce
Applicable protocol Applicable protocol
http http
Status Status
reserved; do not use outside WebSocket handshake reserved; do not use outside WebSocket handshake
Author/Change controller Author/Change controller
IETF IETF
Specification document(s) Specification document(s)
This document is the relevant specification. This document is the relevant specification.
Related information Related information
None. None.
The |Sec-WebSocket-Key1| and |Sec-WebSocket-Key2| headers are used in The |Sec-WebSocket-Key| and |Sec-WebSocket-Nonce| 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.
10.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
skipping to change at page 54, line 36 skipping to change at page 43, 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.
10.8. Sec-WebSocket-Draft 10.8. 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-Draft Sec-WebSocket-Version
Applicable protocol Applicable protocol
http http
Status Status
reserved; do not use outside WebSocket handshake reserved; do not use outside WebSocket handshake
Author/Change controller Author/Change controller
IETF IETF
Specification document(s) Specification document(s)
This document is the relevant specification. This document is the relevant specification.
Related information Related information
None. None.
The |Sec-WebSocket-Draft| header is used in the WebSocket handshake. The |Sec-WebSocket-Version| header is used in the WebSocket
It is sent from the client to the server to indicate the draft 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
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.
skipping to change at page 56, line 23 skipping to change at page 45, line 23
o The destination, consisting of a /host/ and a /port/. o The destination, consisting of a /host/ and a /port/.
o A /resource name/, which allows for multiple services to be o A /resource name/, which allows for multiple services to be
identified at one host and port. identified at one host and port.
o A /secure/ flag, which is true if the connection is to be o A /secure/ flag, which is true if the connection is to be
encrypted, and false otherwise. encrypted, and false otherwise.
o An ASCII serialization of an origin that is being made responsible o An ASCII serialization of an origin that is being made responsible
for the connection. [ORIGIN] for the connection. [I-D.ietf-websec-origin]
o Optionally a string identifying a protocol that is to be layered o Optionally a string identifying a protocol that is to be layered
over the WebSocket connection. over the WebSocket connection.
The /host/, /port/, /resource name/, and /secure/ flag are usually The /host/, /port/, /resource name/, and /secure/ flag are usually
obtained from a URL using the steps to parse a WebSocket URL's obtained from a URL using the steps to parse a WebSocket URL's
components. These steps fail if the URL does not specify a components. These steps fail if the URL does not specify a
WebSocket. WebSocket.
If a connection can be established, then it is said that the If a connection can be established, then it is said that the
skipping to change at page 58, line 5 skipping to change at page 46, line 17
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.
Special thanks also to Adam Barth for providing a significant amount
of text and background research for the Data Masking section of this
specification.
13. 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
Header", draft-abarth-origin (work in progress),
September 2009,
<http://tools.ietf.org/html/draft-abarth-origin>.
[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.
[RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, [FIPS.180-2.2002]
April 1992. National Institute of Standards and Technology, "Secure
Hash Standard", FIPS PUB 180-2, August 2002, <http://
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.
[RFC2109] Kristol, D. and L. Montulli, "HTTP State Management
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.,
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.
[RFC2965] Kristol, D. and L. Montulli, "HTTP State Management
Mechanism", RFC 2965, October 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.
[RFC3548] Josefsson, S., "The Base16, Base32, and Base64 Data
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.
skipping to change at page 59, line 19 skipping to change at page 48, line 12
[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.
[I-D.ietf-httpstate-cookie]
Barth, A., "HTTP State Management Mechanism",
draft-ietf-httpstate-cookie-20 (work in progress),
December 2010.
[I-D.ietf-websec-origin]
Barth, A., "The Web Origin Concept",
draft-ietf-websec-origin-00 (work in progress),
December 2010.
[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. 138 change blocks. 
995 lines changed or deleted 523 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/