idnits 2.17.1 draft-hixie-thewebsocketprotocol-46.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** The document seems to lack a License Notice according IETF Trust Provisions of 28 Dec 2009, Section 6.b.ii or Provisions of 12 Sep 2009 Section 6.b -- however, there's a paragraph with a matching beginning. Boilerplate error? (You're using the IETF Trust Provisions' Section 6.b License Notice from 12 Feb 2009 rather than one of the newer Notices. See https://trustee.ietf.org/license-info/.) Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([HTML5]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document doesn't use any RFC 2119 keywords, yet has text resembling RFC 2119 boilerplate text. -- The document date (October 6, 2009) is 5316 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'HTML5' -- Possible downref: Non-RFC (?) normative reference: ref. 'ORIGIN' ** Obsolete normative reference: RFC 2109 (Obsoleted by RFC 2965) ** Obsolete normative reference: RFC 2246 (Obsoleted by RFC 4346) ** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) ** Obsolete normative reference: RFC 2965 (Obsoleted by RFC 6265) ** Obsolete normative reference: RFC 3490 (Obsoleted by RFC 5890, RFC 5891) -- Possible downref: Non-RFC (?) normative reference: ref. 'WEBADDRESSES' -- Possible downref: Non-RFC (?) normative reference: ref. 'WSAPI' Summary: 7 errors (**), 0 flaws (~~), 2 warnings (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group I. Hickson 3 Internet-Draft Google, Inc. 4 Intended status: Standards Track October 6, 2009 5 Expires: April 9, 2010 7 The Web Socket protocol 8 draft-hixie-thewebsocketprotocol-46 10 Status of this Memo 12 This Internet-Draft is submitted to IETF in full conformance with the 13 provisions of BCP 78 and BCP 79. 15 Internet-Drafts are working documents of the Internet Engineering 16 Task Force (IETF), its areas, and its working groups. Note that 17 other groups may also distribute working documents as Internet- 18 Drafts. 20 Internet-Drafts are draft documents valid for a maximum of six months 21 and may be updated, replaced, or obsoleted by other documents at any 22 time. It is inappropriate to use Internet-Drafts as reference 23 material or to cite them other than as "work in progress." 25 The list of current Internet-Drafts can be accessed at 26 http://www.ietf.org/ietf/1id-abstracts.txt. 28 The list of Internet-Draft Shadow Directories can be accessed at 29 http://www.ietf.org/shadow.html. 31 This Internet-Draft will expire on April 9, 2010. 33 Copyright Notice 35 Copyright (c) 2009 IETF Trust and the persons identified as the 36 document authors. All rights reserved. 38 This document is subject to BCP 78 and the IETF Trust's Legal 39 Provisions Relating to IETF Documents in effect on the date of 40 publication of this document (http://trustee.ietf.org/license-info). 41 Please review these documents carefully, as they describe your rights 42 and restrictions with respect to this document. 44 Abstract 46 This protocol enables two-way communication between a user agent 47 running untrusted code running in a controlled environment to a 48 remote host that understands the protocol. It is intended to fail to 49 communicate with servers of pre-existing protocols like SMTP or HTTP, 50 while allowing HTTP servers to opt-in to supporting this protocol if 51 desired. It is designed to be easy to implement on the server side. 53 Author's note 55 This document is automatically generated from the same source 56 document as the HTML5 specification. [HTML5] 58 Please send feedback to either the hybi@ietf.org list or the 59 whatwg@whatwg.org list. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 1.1. Background . . . . . . . . . . . . . . . . . . . . . . . . 4 65 1.2. Protocol overview . . . . . . . . . . . . . . . . . . . . 4 66 1.3. Design philosophy . . . . . . . . . . . . . . . . . . . . 6 67 1.4. Security model . . . . . . . . . . . . . . . . . . . . . . 6 68 1.5. Relationship to TCP/IP and HTTP . . . . . . . . . . . . . 6 69 1.6. Establishing a connection . . . . . . . . . . . . . . . . 7 70 2. Conformance requirements . . . . . . . . . . . . . . . . . . . 8 71 2.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 8 72 3. Web Socket URLs . . . . . . . . . . . . . . . . . . . . . . . 9 73 3.1. Parsing Web Socket URLs . . . . . . . . . . . . . . . . . 9 74 3.2. Constructing Web Socket URLs . . . . . . . . . . . . . . . 10 75 4. Client-side requirements . . . . . . . . . . . . . . . . . . . 11 76 4.1. Handshake . . . . . . . . . . . . . . . . . . . . . . . . 11 77 4.2. Data framing . . . . . . . . . . . . . . . . . . . . . . . 19 78 4.3. Closing the connection . . . . . . . . . . . . . . . . . . 20 79 4.4. Handling errors in UTF-8 . . . . . . . . . . . . . . . . . 20 80 5. Server-side requirements . . . . . . . . . . . . . . . . . . . 22 81 5.1. Minimal handshake . . . . . . . . . . . . . . . . . . . . 22 82 5.2. Handshake details . . . . . . . . . . . . . . . . . . . . 23 83 5.3. Data framing . . . . . . . . . . . . . . . . . . . . . . . 24 84 6. Closing the connection . . . . . . . . . . . . . . . . . . . . 25 85 7. Security considerations . . . . . . . . . . . . . . . . . . . 26 86 8. IANA considerations . . . . . . . . . . . . . . . . . . . . . 27 87 8.1. Registration of ws: scheme . . . . . . . . . . . . . . . . 27 88 8.2. Registration of wss: scheme . . . . . . . . . . . . . . . 28 89 8.3. Registration of the "WebSocket" HTTP Upgrade keyword . . . 29 90 8.4. WebSocket-Origin . . . . . . . . . . . . . . . . . . . . . 29 91 8.5. WebSocket-Protocol . . . . . . . . . . . . . . . . . . . . 30 92 8.6. WebSocket-Location . . . . . . . . . . . . . . . . . . . . 30 93 9. Using the Web Socket protocol from other specifications . . . 32 94 10. Normative References . . . . . . . . . . . . . . . . . . . . . 33 95 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 35 97 1. Introduction 99 1.1. Background 101 _This section is non-normative._ 103 Historically, creating an instant messenger chat client as a Web 104 application has required an abuse of HTTP to poll the server for 105 updates while sending upstream notifications as distinct HTTP calls. 107 This results in a variety of problems: 109 o The server is forced to use a number of different underlying TCP 110 connections for each client: one for sending information to the 111 client, and a new one for each incoming message. 113 o The wire protocol has a high overhead, with each client-to-server 114 message having an HTTP header. 116 o The client-side script is forced to maintain a mapping from the 117 outgoing connections to the incoming connection to track replies. 119 A simpler solution would be to use a single TCP connection for 120 traffic in both directions. This is what the Web Socket protocol 121 provides. Combined with the Web Socket API, it provides an 122 alternative to HTTP polling for two-way communication from a Web page 123 to a remote server. [WSAPI] 125 The same technique can be used for a variety of Web applications: 126 games, stock tickers, multiuser applications with simultaneous 127 editing, user interfaces exposing server-side services in real time, 128 etc. 130 1.2. Protocol overview 132 _This section is non-normative._ 134 The protocol has two parts: a handshake, and then the data transfer. 136 The handshake from the client looks as follows: 138 GET /demo HTTP/1.1 139 Upgrade: WebSocket 140 Connection: Upgrade 141 Host: example.com 142 Origin: http://example.com 143 WebSocket-Protocol: sample 145 The handshake from the server looks as follows: 147 HTTP/1.1 101 Web Socket Protocol Handshake 148 Upgrade: WebSocket 149 Connection: Upgrade 150 WebSocket-Origin: http://example.com 151 WebSocket-Location: ws://example.com/demo 152 WebSocket-Protocol: sample 154 Once the client and server have both sent their handshakes, and if 155 the handshake was successful, then the data transfer part starts. 156 This is a two-way communication channel where each side can, 157 independently from the other, send data at will. 159 Data is sent in the form of UTF-8 text. Each frame of data starts 160 with a 0x00 byte and ends with a 0xFF byte, with the UTF-8 text in 161 between. 163 The Web Socket protocol uses this framing so that specifications that 164 use the Web Socket protocol can expose such connections using an 165 event-based mechanism instead of requiring users of those 166 specifications to implement buffering and piecing together of 167 messages manually. 169 The protocol is designed to support other frame types in future. 170 Instead of the 0x00 byte, other bytes might in future be defined. 171 Frames denoted by bytes that do not have the high bit set (0x00 to 172 0x7F) are treated as described above (a stream of bytes terminated by 173 0xFF). Frames denoted by bytes that have the high bit set (0x80 to 174 0xFF) or equal to 0x80) have a leading length indicator, which is 175 encoded as a series of 7-bit bytes stored in octets with the 8th bit 176 being set for all but the last byte. The remainder of the frame is 177 then as much data as was specified. 179 The following diagrams summarise the protocol: 181 Handshake 182 | 183 \|/ 184 Frame type byte <-------------------------------------. 185 | | | 186 | `-- (0x00 .. 0x7F) --> Data... --> 0xFF -->-+ 187 | | 188 `-- (0x80 .. 0xFF) --> Length --> Data... ------->-' 190 1.3. Design philosophy 192 _This section is non-normative._ 194 The Web Socket protocol is designed on the principle that there 195 should be minimal framing (the only framing that exists is to make 196 the protocol frame-based instead of stream-based, and to support a 197 distinction between Unicode text and binary frames). It is expected 198 that metadata would be layered on top of Web Socket by the 199 application layer, in the same way that metadata is layered on top of 200 TCP/IP by the application layer (HTTP). 202 Conceptually, Web Socket is really just a layer on top of TCP/IP that 203 adds a Web "origin"-based security model for browsers; adds an 204 addressing and protocol naming mechanism to support multiple services 205 on one port and multiple host names on one IP address; and layers a 206 framing mechanism on top of TCP to get back to the IP packet 207 mechanism that TCP is built on, but without length limits. Other 208 than that, it adds nothing. Basically it is intended to be as close 209 as possible to just exposing raw TCP/IP to script as possible given 210 the constraints of the Web. It's also designed in such a way that its 211 servers can share a port with HTTP servers, by having its handshake 212 be a valid HTTP Upgrade handshake also. 214 1.4. Security model 216 _This section is non-normative._ 218 The Web Socket protocol uses the origin model used by Web browsers to 219 restrict which Web pages can contact a Web Socket server when the Web 220 Socket protocol is used from a Web page. Naturally, when the Web 221 Socket protocol is used directly (not from a Web page), the origin 222 model is not useful, as the client can provide any arbitrary origin 223 string. 225 1.5. Relationship to TCP/IP and HTTP 227 _This section is non-normative._ 229 The Web Socket protocol is an independent TCP-based protocol. Its 230 only relationship to HTTP is that its handshake is interpreted by 231 HTTP servers as an Upgrade request. 233 Based on the expert recommendation of the IANA, the Web Socket 234 protocol by default uses port 80 for regular Web Socket connections 235 and port 443 for Web Socket connections tunneled over TLS. 237 1.6. Establishing a connection 239 _This section is non-normative._ 241 There are several options for establishing a Web Socket connection. 243 The simplest method is to use port 80 to get a direct connection to a 244 Web Socket server. Port 80 traffic, however, will often be 245 intercepted by HTTP proxies, which can lead to the connection failing 246 to be established. 248 The second simplest method is to use TLS encryption and port 443 to 249 connect directly to a Web Socket server. This has the advantage of 250 being more secure; however, TLS encryption can be computationally 251 expensive. 253 When a connection is to be made to a port that is shared by an HTTP 254 server (a situation that is quite likely to occur with traffic to 255 ports 80 and 443), the connection will appear to the HTTP server to 256 be a regular GET request with an Upgrade offer. In relatively simple 257 setups with just one IP address and a single server for all traffic 258 to a single hostname, this might allow a practical way for systems 259 based on the Web Socket protocol to be deployed. In more elaborate 260 setups (e.g. with load balancers and multiple servers), a dedicated 261 set of hosts for Web Socket connections separate from the HTTP 262 servers is probably easier to manage. 264 2. Conformance requirements 266 All diagrams, examples, and notes in this specification are non- 267 normative, as are all sections explicitly marked non-normative. 268 Everything else in this specification is normative. 270 The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", 271 "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this 272 document are to be interpreted as described in RFC2119. For 273 readability, these words do not appear in all uppercase letters in 274 this specification. [RFC2119] 276 Requirements phrased in the imperative as part of algorithms (such as 277 "strip any leading space characters" or "return false and abort these 278 steps") are to be interpreted with the meaning of the key word 279 ("must", "should", "may", etc) used in introducing the algorithm. 281 Conformance requirements phrased as algorithms or specific steps may 282 be implemented in any manner, so long as the end result is 283 equivalent. (In particular, the algorithms defined in this 284 specification are intended to be easy to follow, and not intended to 285 be performant.) 287 Implementations may impose implementation-specific limits on 288 otherwise unconstrained inputs, e.g. to prevent denial of service 289 attacks, to guard against running out of memory, or to work around 290 platform-specific limitations. 292 The conformance classes defined by this specification are user agents 293 and servers. 295 2.1. Terminology 297 *Converting a string to ASCII lowercase* means replacing all 298 characters in the range U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER 299 A to LATIN CAPITAL LETTER Z) with the corresponding characters in the 300 range U+0061 .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL 301 LETTER Z). 303 The term "URL" is used in this section in a manner consistent with 304 the terminology used in HTML, namely, to denote a string that might 305 or might not be a valid URI or IRI and to which certain error 306 handling behaviors will be applied when the string is parsed. 307 [HTML5] 309 3. Web Socket URLs 311 3.1. Parsing Web Socket URLs 313 The steps to *parse a Web Socket URL's components* from a string 314 /url/ are as follows. These steps return either a /host/, a /port/, 315 a /resource name/, and a /secure/ flag, or they fail. 317 1. If /protocol/ is specified but is either the empty string or 318 contains characters that are not in the range U+0021 .. U+007E, 319 then fail this algorithm. 321 2. If the /url/ string is not an absolute URL, then fail this 322 algorithm. [WEBADDRESSES] 324 3. Resolve the /url/ string using the resolve a Web address 325 algorithm defined by the Web addresses specification, with the 326 URL character encoding set to UTF-8. [WEBADDRESSES] [RFC3629] 328 NOTE: It doesn't matter what it is resolved relative to, since 329 we already know it is an absolute URL at this point. 331 4. If /url/ does not have a component whose value is 332 either "ws" or "wss", when compared in an ASCII case-insensitive 333 manner, then fail this algorithm. 335 5. If the component of /url/ is "ws", set /secure/ to 336 false; otherwise, the component is "wss", set /secure/ 337 to true. 339 6. Let /host/ be the value of the component of /url/, 340 converted to ASCII lowercase. 342 7. If /url/ has a component, then let /port/ be that 343 component's value; otherwise, there is no explicit /port/. 345 8. If there is no explicit /port/, then: if /secure/ is false, let 346 /port/ be 80, otherwise let /port/ be 443. 348 9. Let /resource name/ be the value of the component (which 349 might be empty) of /url/. 351 10. If /resource name/ is the empty string, set it to a single 352 character U+002F SOLIDUS (/). 354 11. If /url/ has a component, then append a single U+003F 355 QUESTION MARK character (?) to /resource name/, followed by the 356 value of the component. 358 12. Return /host/, /port/, /resource name/, and /secure/. 360 3.2. Constructing Web Socket URLs 362 The steps to *construct a Web Socket URL* from a /host/, a /port/, a 363 /resource name/, and a /secure/ flag, are as follows: 365 1. Let /url/ be the empty string. 367 2. If the /secure/ flag is false, then append the string "ws://" to 368 /url/. Otherwise, append the string "wss://" to /url/. 370 3. Append /host/ to /url/. 372 4. If the /secure/ flag is false and port is not 80, or if the 373 /secure/ flag is true and port is not 443, then append the string 374 ":" followed by /port/ to /url/. 376 5. Append /resource name/ to /url/. 378 6. Return /url/. 380 4. Client-side requirements 382 _This section only applies to user agents, not to servers._ 384 NOTE: This specification doesn't currently define a limit to the 385 number of simultaneous connections that a client can establish to a 386 server. 388 4.1. Handshake 390 When the user agent is to *establish a Web Socket connection* to a 391 host /host/, on a port /port/, from an origin whose ASCII 392 serialization is /origin/, with a flag /secure/, with a string giving 393 a /resource name/, and optionally with a string giving a /protocol/, 394 it must run the following steps. The /resource name/ string must 395 start with a U+002F SOLIDUS character (/). [ORIGIN] 397 1. If the user agent already has a Web Socket connection to the 398 remote host (IP address) identified by /host/, even if known by 399 another name, wait until that connection has been established or 400 for that connection to have failed. 402 NOTE: This makes it harder for a script to perform a denial of 403 service attack by just opening a large number of Web Socket 404 connections to a remote host. 406 NOTE: There is no limit to the number of established Web Socket 407 connections a user agent can have with a single remote host. 408 Servers can refuse to connect users with an excessive number of 409 connections, or disconnect resource-hogging users when suffering 410 high load. 412 2. _Connect_: If the user agent is configured to use a proxy when 413 using the Web Socket protocol to connect to host /host/ and/or 414 port /port/, then connect to that proxy and ask it to open a 415 TCP/IP connection to the host given by /host/ and the port given 416 by /port/. 418 EXAMPLE: For example, if the user agent uses an HTTP proxy 419 for all traffic, then if it was to try to connect to port 80 420 on server example.com, it might send the following lines to 421 the proxy server: 423 CONNECT example.com:80 HTTP/1.1 424 Host: example.com 426 If there was a password, the connection might look like: 428 CONNECT example.com:80 HTTP/1.1 429 Host: example.com 430 Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE= 432 Otherwise, if the user agent is not configured to use a proxy, 433 then open a TCP/IP connection to the host given by /host/ and 434 the port given by /port/. 436 NOTE: Implementations that do not expose explicit UI for 437 selecting a proxy for Web Socket connections separate from other 438 proxies are encouraged to use a SOCKS proxy for Web Socket 439 connections, if available, or failing that, to prefer the proxy 440 configured for HTTPS connections over the proxy configured for 441 HTTP connections. 443 For the purpose of proxy autoconfiguration scripts, the URL to 444 pass the function must be constructed from /host/, /port/, 445 /resource name/, and the /secure/ flag using the steps to 446 construct a Web Socket URL. 448 NOTE: The WebSocket protocol can be identified in proxy 449 autoconfiguration scripts from the scheme ("ws:" for unencrypted 450 connections and "wss:" for encrypted connections). 452 3. If the connection could not be opened, then fail the Web Socket 453 connection and abort these steps. 455 4. If /secure/ is true, perform a TLS handshake over the 456 connection. If this fails (e.g. the server's certificate could 457 not be verified), then fail the Web Socket connection and abort 458 these steps. Otherwise, all further communication on this 459 channel must run through the encrypted tunnel. [RFC2246] 461 5. Send the following bytes to the remote side (the server): 463 47 45 54 20 465 Send the /resource name/ value, encoded as US-ASCII. 467 Send the following bytes: 469 20 48 54 54 50 2F 31 2E 31 0D 0A 55 70 67 72 61 470 64 65 3A 20 57 65 62 53 6F 63 6B 65 74 0D 0A 43 471 6F 6E 6E 65 63 74 69 6F 6E 3A 20 55 70 67 72 61 472 64 65 0D 0A 474 NOTE: The string "GET ", the path, " HTTP/1.1", CRLF, the string 475 "Upgrade: WebSocket", CRLF, and the string "Connection: 477 Upgrade", CRLF. 479 6. Send the following bytes: 481 48 6F 73 74 3A 20 483 Send the /host/ value, converted to ASCII lowercase, and encoded 484 as US-ASCII. 486 If /secure/ is false, and /port/ is not 80, or if /secure/ is 487 true, and /port/ is not 443, then send an 0x3A byte (ASCII :) 488 followed by the value of /port/, expressed as a base-ten 489 integer, encoded as US-ASCII. 491 Send the following bytes: 493 0D 0A 495 NOTE: The string "Host: ", the host, and CRLF. 497 7. Send the following bytes: 499 4F 72 69 67 69 6E 3A 20 501 Send the /origin/ value, converted to ASCII lowercase, encoded 502 as US-ASCII. [ORIGIN] 504 NOTE: The /origin/ value is a string that was passed to this 505 algorithm. 507 Send the following bytes: 509 0D 0A 511 NOTE: The string "Origin: ", the origin, and CRLF. 513 8. If there is no /protocol/, then skip this step. 515 Otherwise, send the following bytes: 517 57 65 62 53 6F 63 6B 65 74 2D 50 72 6F 74 6F 63 518 6F 6C 3A 20 520 Send the /protocol/ value, encoded as US-ASCII. 522 Send the following bytes: 524 0d 0a 526 NOTE: The string "WebSocket-Protocol: ", the protocol, and CRLF. 528 9. If the client has any authentication information or cookies that 529 would be relevant to a resource accessed over HTTP, if /secure/ 530 is false, or HTTPS, if it is true, on host /host/, port /port/, 531 with /resource name/ as the path (and possibly query 532 parameters), then HTTP headers that would be appropriate for 533 that information should be sent at this point. [RFC2616] 534 [RFC2109] [RFC2965] 536 Each header must be on a line of its own (each ending with a CR 537 LF sequence). For the purposes of this step, each header must 538 not be split into multiple lines (despite HTTP otherwise 539 allowing this with continuation lines). 541 EXAMPLE: For example, if the server had a username and 542 password that applied to |http://example.com/socket|, and the 543 Web Socket was being opened to |ws://example.com/socket|, it 544 could send them: 546 Authorization: Basic d2FsbGU6ZXZl 548 10. Send the following bytes: 550 0d 0a 552 NOTE: Just a CRLF (a blank line). 554 11. Read bytes from the server until either the connection closes, 555 or a 0x0A byte is read. Let /header/ be these bytes, including 556 the 0x0A byte. 558 If /header/ is not at least two bytes long, or if the last two 559 bytes aren't 0x0D and 0x0A respectively, then fail the Web 560 Socket connection and abort these steps. 562 User agents may apply a timeout to this step, failing the Web 563 Socket connection if the server does not send back data in a 564 suitable time period. 566 12. If /header/ consists of 44 bytes that exactly match the 567 following, then let /mode/ be _normal_. 569 48 54 54 50 2F 31 2E 31 20 31 30 31 20 57 65 62 570 20 53 6F 63 6B 65 74 20 50 72 6F 74 6F 63 6F 6C 571 20 48 61 6E 64 73 68 61 6B 65 0D 0A 573 NOTE: The string "HTTP/1.1 101 Web Socket Protocol Handshake" 574 followed by a CRLF pair. 576 Otherwise, let /code/ be the substring of /header/ that starts 577 from the byte after the first 0x20 byte, and ends with the byte 578 before the second 0x20 byte. If there are not at least two 0x20 579 bytes in /header/, then fail the Web Socket connection and abort 580 these steps. 582 If /code/, interpreted as ASCII, is "401", then let /mode/ be 583 _authenticate_. 585 Otherwise, fail the Web Socket connection and abort these steps. 587 13. If /mode/ is _normal_, then read 41 bytes from the server. 589 If the connection closes before 41 bytes are received, or if the 590 41 bytes aren't exactly equal to the following bytes, then fail 591 the Web Socket connection and abort these steps. 593 55 70 67 72 61 64 65 3A 20 57 65 62 53 6F 63 6B 594 65 74 0D 0A 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 595 55 70 67 72 61 64 65 0D 0A 597 NOTE: The string "Upgrade: WebSocket", CRLF, the string 598 "Connection: Upgrade", CRLF. 600 User agents may apply a timeout to this step, failing the Web 601 Socket connection if the server does not respond with the above 602 bytes within a suitable time period. 604 NOTE: This step is skipped if /mode/ is _authenticate_. 606 14. Let /headers/ be a list of name-value pairs, initially empty. 608 15. _Header_: Let /name/ and /value/ be empty byte arrays. 610 16. Read a byte from the server. 612 If the connection closes before this byte is received, then fail 613 the Web Socket connection and abort these steps. 615 Otherwise, handle the byte as described in the appropriate entry 616 below: 618 -> If the byte is 0x0D (ASCII CR) 619 If the /name/ byte array is empty, then jump to the headers 620 processing step. Otherwise, fail the Web Socket connection 621 and abort these steps. 623 -> If the byte is 0x0A (ASCII LF) 624 Fail the Web Socket connection and abort these steps. 626 -> If the byte is 0x3A (ASCII :) 627 Move on to the next step. 629 -> If the byte is in the range 0x41 .. 0x5A (ASCII A .. Z) 630 Append a byte whose value is the byte's value plus 0x20 to 631 the /name/ byte array and redo this step for the next byte. 633 -> Otherwise 634 Append the byte to the /name/ byte array and redo this step 635 for the next byte. 637 NOTE: This reads a header name, terminated by a colon, 638 converting upper-case ASCII letters to lowercase, and aborting 639 if a stray CR or LF is found. 641 17. Read a byte from the server. 643 If the connection closes before this byte is received, then fail 644 the Web Socket connection and abort these steps. 646 Otherwise, handle the byte as described in the appropriate entry 647 below: 649 -> If the byte is 0x20 (ASCII space) 650 Ignore the byte and move on to the next step. 652 -> Otherwise 653 Treat the byte as described by the list in the next step, 654 then move on to that next step for real. 656 NOTE: This skips past a space character after the colon, if 657 necessary. 659 18. Read a byte from the server. 661 If the connection closes before this byte is received, then fail 662 the Web Socket connection and abort these steps. 664 Otherwise, handle the byte as described in the appropriate entry 665 below: 667 -> If the byte is 0x0D (ASCII CR) 668 Move on to the next step. 670 -> If the byte is 0x0A (ASCII LF) 671 Fail the Web Socket connection and abort these steps. 673 -> Otherwise 674 Append the byte to the /value/ byte array and redo this step 675 for the next byte. 677 NOTE: This reads a header value, terminated by a CRLF. 679 19. Read a byte from the server. 681 If the connection closes before this byte is received, or if the 682 byte is not a 0x0A byte (ASCII LF), then fail the Web Socket 683 connection and abort these steps. 685 NOTE: This skips past the LF byte of the CRLF after the header. 687 20. Append an entry to the /headers/ list that has the name given by 688 the string obtained by interpreting the /name/ byte array as a 689 UTF-8 byte stream and the value given by the string obtained by 690 interpreting the /value/ byte array as a UTF-8 byte stream. 692 21. Return to the "Header" step above. 694 22. _Headers processing_: Read a byte from the server. 696 If the connection closes before this byte is received, or if the 697 byte is not a 0x0A byte (ASCII LF), then fail the Web Socket 698 connection and abort these steps. 700 NOTE: This skips past the LF byte of the CRLF after the blank 701 line after the headers. 703 23. If /mode/ is _normal_, then: If there is not exactly one entry 704 in the /headers/ list whose name is "websocket-origin", or if 705 there is not exactly one entry in the /headers/ list whose name 706 is "websocket-location", or if the /protocol/ was specified but 707 there is not exactly one entry in the /headers/ list whose name 708 is "websocket-protocol", or if there are any entries in the 709 /headers/ list whose names are the empty string, then fail the 710 Web Socket connection and abort these steps. Otherwise, handle 711 each entry in the /headers/ list as follows: 713 -> If the entry's name is "websocket-origin" 714 If the value is not exactly equal to /origin/, converted to 715 ASCII lowercase, then fail the Web Socket connection and 716 abort these steps. [ORIGIN] 718 -> If the entry's name is "websocket-location" 719 If the value is not exactly equal to a string obtained from 720 the steps to construct a Web Socket URL from /host/, /port/, 721 /resource name/, and the /secure/ flag, then fail the Web 722 Socket connection and abort these steps. 724 -> If the entry's name is "websocket-protocol" 725 If there was a /protocol/ specified, and the value is not 726 exactly equal to /protocol/, then fail the Web Socket 727 connection and abort these steps. (If no /protocol/ was 728 specified, the header is ignored.) 730 -> If the entry's name is "set-cookie" or "set-cookie2" or 731 another cookie-related header name 732 Handle the cookie as defined by the appropriate 733 specification, with the resource being the one with the host 734 /host/, the port /port/, the path (and possibly query 735 parameters) /resource name/, and the scheme |http| if 736 /secure/ is false and |https| if /secure/ is true. [RFC2109] 737 [RFC2965] 739 -> Any other name 740 Ignore it. 742 If /mode/ is _authenticate_, then: If there is not exactly one 743 entry in the /headers/ list whose name is "www-authenticate", 744 then fail the Web Socket connection and abort these steps. 745 Otherwise, handle each entry in the /headers/ list as follows: 747 -> If the entry's name is "www-authenticate" 748 Obtain credentials in a manner consistent with the 749 requirements for handling the |WWW-Authenticate| header in 750 HTTP, and then close the connection (if the server has not 751 already done so) and jump back to the step labeled _connect_, 752 including the relevant authentication headers in the new 753 request. [RFC2616] 755 -> Any other name 756 Ignore it. 758 24. The *Web Socket connection is established*. Now the user agent 759 must send and receive to and from the connection as described in 760 the next section. 762 4.2. Data framing 764 Once a Web Socket connection is established, the user agent must run 765 through the following state machine for the bytes sent by the server. 767 1. Try to read a byte from the server. Let /frame type/ be that 768 byte. 770 If no byte could be read because the Web Socket connection is 771 closed, then abort. 773 2. Handle the /frame type/ byte as follows: 775 If the high-order bit of the /frame type/ byte is set (i.e. if 776 /frame type/ _and_ed with 0x80 returns 0x80) 777 Run these steps. If at any point during these steps a read is 778 attempted but fails because the Web Socket connection is 779 closed, then abort. 781 1. Let /length/ be zero. 783 2. _Length_: Read a byte, let /b/ be that byte. 785 3. Let /b_v/ be integer corresponding to the low 7 bits of 786 /b/ (the value you would get by _and_ing /b/ with 0x7F). 788 4. Multiply /length/ by 128, add /b_v/ to that result, and 789 store the final result in /length/. 791 5. If the high-order bit of /b/ is set (i.e. if /b/ _and_ed 792 with 0x80 returns 0x80), then return to the step above 793 labeled _length_. 795 6. Read /length/ bytes. 797 7. Discard the read bytes. 799 If the high-order bit of the /frame type/ byte is _not_ set (i.e. 800 if /frame type/ _and_ed with 0x80 returns 0x00) 801 Run these steps. If at any point during these steps a read is 802 attempted but fails because the Web Socket connection is 803 closed, then abort. 805 1. Let /raw data/ be an empty byte array. 807 2. _Data_: Read a byte, let /b/ be that byte. If the client 808 runs out of resources for buffering the incoming data, or 809 hits an artificial resource limit intended to avoid 810 resource starvation, then it must fail the Web Socket 811 connection and abort these steps. 813 3. If /b/ is not 0xFF, then append /b/ to /raw data/ and 814 return to the previous step (labeled _data_). 816 4. Interpret /raw data/ as a UTF-8 string, and store that 817 string in /data/. 819 5. If /frame type/ is 0x00, then *a message has been 820 received* with text /data/. Otherwise, discard the data. 822 3. Return to the first step to read the next byte. 824 If the user agent is faced with content that is too large to be 825 handled appropriately, then it must fail the Web Socket connection. 827 Once a Web Socket connection is established, the user agent must use 828 the following steps to *send /data/ using the Web Socket*: 830 1. Send a 0x00 byte to the server. 832 2. Encode /data/ using UTF-8 and send the resulting byte stream to 833 the server. 835 3. Send a 0xFF byte to the server. 837 If at any point there is a fatal problem with sending data to the 838 server, the user agent must fail the Web Socket connection. 840 4.3. Closing the connection 842 To *fail the Web Socket connection*, the user agent must close the 843 Web Socket connection, and may report the problem to the user (which 844 would be especially useful for developers). However, user agents 845 must not convey the failure information to the script that attempted 846 the connection in a way distinguishable from the Web Socket being 847 closed normally. 849 Except as indicated above or as specified by the application layer 850 (e.g. a script using the Web Socket API), user agents should not 851 close the connection. 853 4.4. Handling errors in UTF-8 855 When a client is to interpret a byte stream as UTF-8 but finds that 856 the byte stream is not in fact a valid UTF-8 stream, then any bytes 857 or sequences of bytes that are not valid UTF-8 sequences must be 858 interpreted as a U+FFFD REPLACEMENT CHARACTER. 860 5. Server-side requirements 862 _This section only applies to servers._ 864 5.1. Minimal handshake 866 NOTE: This section describes the minimal requirements for a server- 867 side implementation of Web Sockets. 869 Listen on a port for TCP/IP. Upon receiving a connection request, 870 open a connection and send the following bytes back to the client: 872 48 54 54 50 2F 31 2E 31 20 31 30 31 20 57 65 62 873 20 53 6F 63 6B 65 74 20 50 72 6F 74 6F 63 6F 6C 874 20 48 61 6E 64 73 68 61 6B 65 0D 0A 55 70 67 72 875 61 64 65 3A 20 57 65 62 53 6F 63 6B 65 74 0D 0A 876 43 6F 6E 6E 65 63 74 69 6F 6E 3A 20 55 70 67 72 877 61 64 65 0D 0A 879 Send the string "WebSocket-Origin" followed by a U+003A COLON (:) and 880 a U+0020 SPACE, followed by the ASCII serialization of the origin 881 from which the server is willing to accept connections, followed by a 882 CRLF pair (0x0D 0x0A). [ORIGIN] 884 For instance: 886 WebSocket-Origin: http://example.com 888 Send the string "WebSocket-Location" followed by a U+003A COLON (:) 889 and a U+0020 SPACE, followed by the URL of the Web Socket script, 890 followed by a CRLF pair (0x0D 0x0A). 892 For instance: 894 WebSocket-Location: ws://example.com/demo 896 NOTE: Do not include the port if it is the default port for Web 897 Socket protocol connections of the type in question (80 for 898 unencrypted connections and 443 for encrypted connections). 900 Send another CRLF pair (0x0D 0x0A). 902 Read data from the client until four bytes 0x0D 0x0A 0x0D 0x0A are 903 read. This data must either be discarded or handled as described in 904 the following section describing the handshake details. 906 If the connection isn't dropped at this point, go to the data framing 907 section. 909 5.2. Handshake details 911 The previous section ignores the data that is transmitted by the 912 client during the handshake. 914 The data sent by the client consists of a number of fields separated 915 by CR LF pairs (bytes 0x0D 0x0A). 917 The first field consists of three tokens separated by space 918 characters (byte 0x20). The middle token is the path being opened. 919 If the server supports multiple paths, then the server should echo 920 the value of this field in the initial handshake, as part of the URL 921 given on the |WebSocket-Location| line (after the appropriate scheme 922 and host). 924 If the first field does not have three tokens, the server should 925 abort the connection as it probably represents an errorneous client. 927 The remaining fields consist of name-value pairs, with the name part 928 separated from the value part by a colon and a space (bytes 0x3A 929 0x20). Of these, several are interesting: 931 Host (bytes 48 6F 73 74) 932 The value gives the hostname that the client intended to use when 933 opening the Web Socket. It would be of interest in particular to 934 virtual hosting environments, where one server might serve 935 multiple hosts, and might therefore want to return different data. 937 The right host has to be output as part of the URL given on the 938 |WebSocket-Location| line of the handshake described above, to 939 verify that the server knows that it is really representing that 940 host. 942 Origin (bytes 4F 72 69 67 69 6E) 943 The value gives the scheme, hostname, and port (if it's not the 944 default port for the given scheme) of the page that asked the 945 client to open the Web Socket. It would be interesting if the 946 server's operator had deals with operators of other sites, since 947 the server could then decide how to respond (or indeed, _whether_ 948 to respond) based on which site was requesting a connection. 950 If the server supports connections from more than one origin, then 951 the server should echo the value of this field in the initial 952 handshake, on the |WebSocket-Origin| line. 954 Other fields 955 Other fields can be used, such as "Cookie" or "Authorization", for 956 authentication purposes. 958 Any fields that lack the colon-space separator should be discarded 959 and may cause the server to disconnect. 961 5.3. Data framing 963 NOTE: This section only describes how to handle content that this 964 specification allows user agents to send (text). It doesn't handle 965 any arbitrary content in the same way that the requirements on user 966 agents defined earlier handle any content including possible future 967 extensions to the protocols. 969 The server must run through the following steps to process the bytes 970 sent by the client: 972 1. Read a byte from the client. Assuming everything is going 973 according to plan, it will be a 0x00 byte. If the byte is not a 974 0x00 byte, then the server may disconnect. 976 2. Let /raw data/ be an empty byte array. 978 3. _Data_: Read a byte, let /b/ be that byte. 980 4. If /b/ is not 0xFF, then append /b/ to /raw data/ and return to 981 the previous step (labeled _data_). 983 5. Interpret /raw data/ as a UTF-8 string, and apply whatever 984 server-specific processing is to occur for the resulting string. 986 6. Return to the first step to read the next byte. 988 The server must run through the following steps to send strings to 989 the client: 991 1. Send a 0x00 byte to the client to indicate the start of a string. 993 2. Encode /data/ using UTF-8 and send the resulting byte stream to 994 the client. 996 3. Send a 0xFF byte to the client to indicate the end of the 997 message. 999 6. Closing the connection 1001 To *close the Web Socket connection*, either the user agent or the 1002 server closes the TCP/IP connection. There is no closing handshake. 1003 Whether the user agent or the server closes the connection, it is 1004 said that the *Web Socket connection is closed*. 1006 When a user agent is to close the Web Socket connection, it must drop 1007 all subsequent data from the server and must act as if the server had 1008 immediately closed its side of the connection. 1010 When a user agent notices that the Web Socket connection is closed, 1011 it must immediately close its side of the connection. 1013 Servers may close the Web Socket connection whenever desired. 1015 User agents should not close the Web Socket connection arbitrarily. 1017 7. Security considerations 1019 While this protocol is intended to be used by scripts in Web pages, 1020 it can also be used directly by hosts. Such hosts are acting on 1021 their own behalf, and can therefore send fake "Origin" headers, 1022 misleading the server. Servers should therefore be careful about 1023 assuming that they are talking directly to scripts from known 1024 origins, and must consider that they might be accessed in unexpected 1025 ways. In particular, a server should not trust that any input is 1026 valid. 1028 EXAMPLE: For example, if the server uses input as part of SQL 1029 queries, all input text should be escaped before being passed to the 1030 SQL server, lest the server be susceptible to SQL injection. 1032 Servers that are not intended to process input from any Web page but 1033 only for certain sites should verify the "Origin" header is an origin 1034 they expect, and should only respond with the corresponding 1035 "WebSocket-Origin" if it is an accepted origin. Servers that only 1036 accept input from one origin can just send back that value in the 1037 "WebSocket-Origin" header, without bothering to check the client's 1038 value. 1040 If at any time a server is faced with data that it does not 1041 understand, or that violates some criteria by which the server 1042 determines safety of input, or when the server sees a handshake that 1043 does not correspond to the values the server is expecting (e.g. 1044 incorrect path or origin), the server should just disconnect. It is 1045 always safe to disconnect. 1047 8. IANA considerations 1049 8.1. Registration of ws: scheme 1051 A |ws:| URL identifies a Web Socket server and resource name. 1053 URI scheme name. 1054 ws 1056 Status. 1057 Permanent. 1059 URI scheme syntax. 1060 In ABNF terms using the terminals from the URI specifications: 1061 [RFC5234] [RFC3986] 1063 "ws" ":" hier-part [ "?" query ] 1065 The path and query components form the resource name sent to the 1066 server to identify the kind of service desired. Other components 1067 have the meanings described in RFC3986. 1069 URI scheme semantics. 1070 The only operation for this scheme is to open a connection using 1071 the Web Socket protocol. 1073 Encoding considerations. 1074 Characters in the host component that are excluded by the syntax 1075 defined above must be converted from Unicode to ASCII by applying 1076 the IDNA ToASCII algorithm to the Unicode host name, with both the 1077 AllowUnassigned and UseSTD3ASCIIRules flags set, and using the 1078 result of this algorithm as the host in the URI. [RFC3490] 1080 Characters in other components that are excluded by the syntax 1081 defined above must be converted from Unicode to ASCII by first 1082 encoding the characters as UTF-8 and then replacing the 1083 corresponding bytes using their percent-encoded form as defined in 1084 the URI and IRI specification. [RFC3986] [RFC3987] 1086 Applications/protocols that use this URI scheme name. 1087 Web Socket protocol. 1089 Interoperability considerations. 1090 None. 1092 Security considerations. 1093 See "Security considerations" section above. 1095 Contact. 1096 Ian Hickson 1098 Author/Change controller. 1099 Ian Hickson 1101 References. 1102 This document. 1104 8.2. Registration of wss: scheme 1106 A |wss:| URL identifies a Web Socket server and resource name, and 1107 indicates that traffic over that connection is to be encrypted. 1109 URI scheme name. 1110 wss 1112 Status. 1113 Permanent. 1115 URI scheme syntax. 1116 In ABNF terms using the terminals from the URI specifications: 1117 [RFC5234] [RFC3986] 1119 "wss" ":" hier-part [ "?" query ] 1121 The path and query components form the resource name sent to the 1122 server to identify the kind of service desired. Other components 1123 have the meanings described in RFC3986. 1125 URI scheme semantics. 1126 The only operation for this scheme is to open a connection using 1127 the Web Socket protocol, encrypted using TLS. 1129 Encoding considerations. 1130 Characters in the host component that are excluded by the syntax 1131 defined above must be converted from Unicode to ASCII by applying 1132 the IDNA ToASCII algorithm to the Unicode host name, with both the 1133 AllowUnassigned and UseSTD3ASCIIRules flags set, and using the 1134 result of this algorithm as the host in the URI. [RFC3490] 1136 Characters in other components that are excluded by the syntax 1137 defined above must be converted from Unicode to ASCII by first 1138 encoding the characters as UTF-8 and then replacing the 1139 corresponding bytes using their percent-encoded form as defined in 1140 the URI and IRI specification. [RFC3986] [RFC3987] 1142 Applications/protocols that use this URI scheme name. 1143 Web Socket protocol over TLS. 1145 Interoperability considerations. 1146 None. 1148 Security considerations. 1149 See "Security considerations" section above. 1151 Contact. 1152 Ian Hickson 1154 Author/Change controller. 1155 Ian Hickson 1157 References. 1158 This document. 1160 8.3. Registration of the "WebSocket" HTTP Upgrade keyword 1162 Name of token. 1163 WebSocket 1165 Author/Change controller. 1166 Ian Hickson 1168 Contact. 1169 Ian Hickson 1171 References. 1172 This document. 1174 8.4. WebSocket-Origin 1176 This section describes a header field for registration in the 1177 Permanent Message Header Field Registry. [RFC3864] 1179 Header field name 1180 WebSocket-Origin 1182 Applicable protocol 1183 http 1185 Status 1186 reserved; do not use outside WebSocket handshake 1188 Author/Change controller 1189 IETF 1191 Specification document(s) 1192 This document is the relevant specification. 1194 Related information 1195 None. 1197 8.5. WebSocket-Protocol 1199 This section describes a header field for registration in the 1200 Permanent Message Header Field Registry. [RFC3864] 1202 Header field name 1203 WebSocket-Protocol 1205 Applicable protocol 1206 http 1208 Status 1209 reserved; do not use outside WebSocket handshake 1211 Author/Change controller 1212 IETF 1214 Specification document(s) 1215 This document is the relevant specification. 1217 Related information 1218 None. 1220 8.6. WebSocket-Location 1222 This section describes a header field for registration in the 1223 Permanent Message Header Field Registry. [RFC3864] 1225 Header field name 1226 WebSocket-Location 1228 Applicable protocol 1229 http 1231 Status 1232 reserved; do not use outside WebSocket handshake 1234 Author/Change controller 1235 IETF 1237 Specification document(s) 1238 This document is the relevant specification. 1240 Related information 1241 None. 1243 9. Using the Web Socket protocol from other specifications 1245 The Web Socket protocol is intended to be used by another 1246 specification to provide a generic mechanism for dynamic author- 1247 defined content, e.g. in a specification defining a scripted API. 1249 Such a specification first needs to "establish a Web Socket 1250 connection", providing that algorithm with: 1252 o The destination, consisting of a /host/ and a /port/. 1254 o A /resource name/, which allows for multiple services to be 1255 identified at one host and port. 1257 o A /secure/ flag, which is true if the connection is to be 1258 encrypted, and false otherwise. 1260 o An ASCII serialization of an origin that is being made responsible 1261 for the connection. [ORIGIN] 1263 o Optionally a string identifying a protocol that is to be layered 1264 over the Web Socket connection. 1266 The /host/, /port/, /resource name/, and /secure/ flag are usually 1267 obtained from a URL using the steps to parse a Web Socket URL's 1268 components. These steps fail if the URL does not specify a Web 1269 Socket. 1271 If a connection can be established, then it is said that the "Web 1272 Socket connection is established". 1274 If at any time the connection is to be closed, then the specification 1275 needs to use the "close the Web Socket connection" algorithm. 1277 When the connection is closed, for any reason including failure to 1278 establish the connection in the first place, it is said that the "Web 1279 Socket connection is closed". 1281 While a connection is open, the specification will need to handle the 1282 cases when "a Web Socket message has been received" with text /data/. 1284 To send some text /data/ to an open connection, the specification 1285 needs to "send /data/ using the Web Socket". 1287 10. Normative References 1289 [HTML5] Hickson, I., "HTML5", October 2009. 1291 [ORIGIN] Barth, A., Jackson, C., and I. Hickson, "The HTTP Origin 1292 Header", September 2009. 1294 [RFC2109] Kristol, D. and L. Montulli, "HTTP State Management 1295 Mechanism", RFC 2109, February 1997. 1297 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1298 Requirement Levels", BCP 14, RFC 2119, March 1997. 1300 [RFC2246] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", 1301 RFC 2246, January 1999. 1303 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 1304 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 1305 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 1307 [RFC2965] Kristol, D. and L. Montulli, "HTTP State Management 1308 Mechanism", RFC 2965, October 2000. 1310 [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, 1311 "Internationalizing Domain Names in Applications (IDNA)", 1312 RFC 3490, March 2003. 1314 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1315 10646", STD 63, RFC 3629, November 2003. 1317 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 1318 Procedures for Message Header Fields", BCP 90, RFC 3864, 1319 September 2004. 1321 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1322 Resource Identifier (URI): Generic Syntax", STD 66, 1323 RFC 3986, January 2005. 1325 [RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource 1326 Identifiers (IRIs)", RFC 3987, January 2005. 1328 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 1329 Specifications: ABNF", STD 68, RFC 5234, January 2008. 1331 [WEBADDRESSES] 1332 Connolly, D. and C. Sperberg-McQueen, "Web addresses in 1333 HTML 5", May 2009. 1335 [WSAPI] Hickson, I., "The Web Sockets API", October 2009. 1337 Author's Address 1339 Ian Hickson 1340 Google, Inc. 1342 Email: ian@hixie.ch 1343 URI: http://ln.hixie.ch/