[html5] r3618 - [] (0) Factor out the definition of how to parse a Web Socket URL, so that there [...]

whatwg at whatwg.org whatwg at whatwg.org
Thu Aug 13 23:56:07 PDT 2009


Author: ianh
Date: 2009-08-13 23:56:07 -0700 (Thu, 13 Aug 2009)
New Revision: 3618

Modified:
   source
Log:
[] (0) Factor out the definition of how to parse a Web Socket URL, so that there's no duplication. Clarify the definitions of ws: and wss:.

Modified: source
===================================================================
--- source	2009-08-14 05:42:35 UTC (rev 3617)
+++ source	2009-08-14 06:56:07 UTC (rev 3618)
@@ -70388,64 +70388,27 @@
    <!-- beware, this is very similar to the steps for what happens
    during a redirect, in the protocol section -->
 
-   <li><p><span title="parse a url">Parse</span> the <var
-   title="">url</var> argument.</p></li>
+   <li><p><span>Parse a Web Socket URL's components</span> from the
+   <var title="">url</var> argument, to obtain <var
+   title="">host</var>, <var title="">port</var>, <var
+   title="">resource name</var>, and <var title="">secure</var>. If
+   this fails, throw a <code>SYNTAX_ERR</code> exception and abort
+   these steps.</p></li>
 
-   <li><p>If the previous step failed, or if <var title="">url</var>
-   does not have a <span title="url-scheme"><scheme></span>
-   component whose value is either "<code title="">ws</code>" or
-   "<code title="">wss</code>", when compared in an <span>ASCII
-   case-insensitive</span> manner, then throw a
-   <code>SYNTAX_ERR</code> exception.</p></li>
+   <li><p>If <var title="">port</var> is a port to which the user
+   agent is configured to block access, then throw a <span>security
+   exception</span>. (User agents typically block access to well-known
+   ports like SMTP.)</p></li>
+   <!--
+    e.g. http://www.mozilla.org/projects/netlib/PortBanning.html
+   -->
 
-   <li><p>If <var title="">protocol</var> is specified but is either
-   the empty string or contains characters that are not in the range
-   U+0021 .. U+007E, then throw a <code>SYNTAX_ERR</code>
-   exception.</p></li>
-
    <li><p>Let <var title="">origin</var> be the <span title="ASCII
    serialization of an origin">ASCII serialization</span> of the
    <span>origin</span> of the script that invoked the <code
    title="dom-WebSocket">WebSocket()</code> constructor,
    <span>converted to ASCII lowercase</span>.</p></li>
 
-   <li><p>If the <span title="url-scheme"><scheme></span>
-   component of <var title="">url</var> is "<code title="">ws</code>",
-   set <var title="">secure</var> to false; otherwise, the <span
-   title="url-scheme"><scheme></span> component is "<code
-   title="">wss</code>", set <var title="">secure</var> to
-   true.</p></li>
-
-   <li><p>Let <var title="">host</var> be the value of the <span
-   title="url-host"><host></span> component of <var
-   title="">url</var>, <span>converted to ASCII lowercase</span>.</p></li>
-
-   <li><p>If <var title="">url</var> has a <span
-   title="url-port"><port></span> component, then let <var
-   title="">port</var> be that component's value; otherwise, there is
-   no explicit <var title="">port</var>.</p></li>
-
-   <li><p>If there is an explicit <var title="">port</var> and the
-   user agent is configured to block access to that port, then throw a
-   <span>security exception</span>. (User agents typically block
-   access to well-known ports like SMTP.)</p></li>
-   <!--
-    e.g. http://www.mozilla.org/projects/netlib/PortBanning.html
-   -->
-
-   <li><p>Let <var title="">resource name</var> be the value of the
-   <span title="url-path"><path></span> component (which might
-   be empty) of <var title="">url</var>.</p></li>
-
-   <li><p>If <var title="">resource name</var> is the empty string,
-   set it to a single character U+002F SOLIDUS (/).</p></li>
-
-   <li><p>If <var title="">url</var> has a <span
-   title="url-query"><query></span> component, then append a
-   single U+003F QUESTION MARK (?) character to <var title="">resource
-   name</var>, followed by the value of the <span
-   title="url-query"><query></span> component.</p></li>
-
    <li><p>Return a new <code>WebSocket</code> object, and continue
    these steps in the background (without blocking scripts).</p></li>
 
@@ -70776,7 +70739,88 @@
 
   <!--BOILERPLATE middle-ietf-conformance-->
 
+  <h6>Terminology</h6>
 
+  <p><dfn title="converted to ASCII lowercase">Converting a string to
+  ASCII lowercase</dfn> means replacing all characters in the range
+  U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL
+  LETTER Z) with the corresponding characters in the range U+0061
+  .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z).</p>
+
+  <p>The term "URL" is used in this section in a manner consistent
+  with the terminology used in HTML, namely, to denote a string that
+  might or might not be a valid URI or IRI and to which certain error
+  handling behaviors will be applied when the string is parsed. <a
+  href="#refsHTML5">[HTML5]</a></p>
+
+
+
+  <h5>Parsing Web Socket URLs</h5>
+
+  <p>The steps to <dfn>parse a Web Socket URL's components</dfn> from
+  a string <var title="">url</var> are as follows. These steps return
+  either a <var title="">host</var>, a <var title="">port</var>, a
+  <var title="">resource name</var>, and a <var title="">secure</var>
+  flag, or they fail.</p>
+
+  <ol>
+
+   <li><p><span title="parse a url">Parse</span> the <var
+   title="">url</var> string using the <span>parse a Web
+   address</span> algorithm defined by the Web addresses
+   specification. <a href="#refsWEBADDRESSES">[WEBADDRESSES]</a></p>
+
+   <li><p>If the previous step failed, or if <var title="">url</var>
+   does not have a <span title="url-scheme"><scheme></span>
+   component whose value is either "<code title="">ws</code>" or
+   "<code title="">wss</code>", when compared in an <span>ASCII
+   case-insensitive</span> manner, then fail this algorithm.</p></li>
+
+   <li><p>If <var title="">protocol</var> is specified but is either
+   the empty string or contains characters that are not in the range
+   U+0021 .. U+007E, then fail this algorithm.</p></li>
+
+   <li><p>If the <span title="url-scheme"><scheme></span>
+   component of <var title="">url</var> is "<code title="">ws</code>",
+   set <var title="">secure</var> to false; otherwise, the <span
+   title="url-scheme"><scheme></span> component is "<code
+   title="">wss</code>", set <var title="">secure</var> to
+   true.</p></li>
+
+   <li><p>Let <var title="">host</var> be the value of the <span
+   title="url-host"><host></span> component of <var
+   title="">url</var>, <span>converted to ASCII
+   lowercase</span>.</p></li>
+
+   <li><p>If <var title="">url</var> has a <span
+   title="url-port"><port></span> component, then let <var
+   title="">port</var> be that component's value; otherwise, there is
+   no explicit <var title="">port</var>.</p></li>
+
+   <li><p>If there is no explicit <var title="">port</var>, then: if
+   <var title="">secure</var> is false, let <var title="">port</var>
+   be 81, otherwise let <var title="">port</var> be 815.</p></li>
+
+   <li><p>Let <var title="">resource name</var> be the value of the
+   <span title="url-path"><path></span> component (which might
+   be empty) of <var title="">url</var>.</p></li>
+
+   <li><p>If <var title="">resource name</var> is the empty string,
+   set it to a single character U+002F SOLIDUS (/).</p></li>
+
+   <li><p>If <var title="">url</var> has a <span
+   title="url-query"><query></span> component, then append a
+   single U+003F QUESTION MARK (?) character to <var title="">resource
+   name</var>, followed by the value of the <span
+   title="url-query"><query></span> component.</p></li>
+
+   <li><p>Return <var title="">host</var>, <var title="">port</var>,
+   <var title="">resource name</var>, and <var
+   title="">secure</var>.</p></li>
+
+  </ol>
+
+
   <h5>Client-side requirements</h5>
 
   <p><i>This section only applies to user agents, not to
@@ -70790,12 +70834,11 @@
   <h6>Handshake</h6>
 
   <p>When the user agent is to <dfn>establish a Web Socket
-  connection</dfn> to a host <var title="">host</var>, optionally on
-  port <var title="">port</var>, from an origin <var
-  title="">origin</var>, with a flag <var title="">secure</var>, with
-  a particular <var title="">resource name</var>, and optionally with
-  a particular <var title="">protocol</var>, it must run the following
-  steps.</p>
+  connection</dfn> to a host <var title="">host</var>, on a port <var
+  title="">port</var>, from an origin <var title="">origin</var>, with
+  a flag <var title="">secure</var>, with a particular <var
+  title="">resource name</var>, and optionally with a particular <var
+  title="">protocol</var>, it must run the following steps.</p>
 
   <p class="note">The <var title="">host</var> and <var
   title="">origin</var> strings will be all-lowercase when this
@@ -70805,14 +70848,6 @@
 
    <li>
 
-    <p>If there is no explicit <var title="">port</var>, then: if <var
-    title="">secure</var> is false, let <var title="">port</var> be 81,
-    otherwise let <var title="">port</var> be 815.</p>
-
-   </li>
-
-   <li>
-
     <p>If the user agent already has a Web Socket connection to the
     remote host (IP address) identified by <var title="">host</var>,
     even if known by another name, wait until that connection has been
@@ -71363,62 +71398,38 @@
 
      <dd>
 
-      <!-- this is very similar to the constructor's steps -->
+      <ol>
 
-      <p><span title="parse a url">Parse</span> the value of the
-      entry. If this fails, or if the parsed <span>URL</span> does not
-      have a <span title="url-scheme"><scheme></span> component
-      whose value is either "<code title="">ws</code>" or "<code
-      title="">wss</code>", when compared in an <span>ASCII
-      case-insensitive</span> manner, then <span>fail the Web Socket
-      connection</span> and abort these steps.</p>
+       <li><p>Let <var title="">was secure</var> have the value of
+       <var title="">secure</var>.</p></li>
 
-      <p>If <var title="">secure</var> is true but the newly parsed
-      <span>URL</span>'s <span
-      title="url-scheme"><scheme></span> component is an
-      <span>ASCII case-insensitive</span> match for "<code
-      title="">ws</code>", then <span>fail the Web Socket
-      connection</span> and abort these steps. Otherwise, if <var
-      title="">secure</var> is false but the newly parsed
-      <span>URL</span>'s <span
-      title="url-scheme"><scheme></span> component is an
-      <span>ASCII case-insensitive</span> match for "<code
-      title="">wss</code>", then set <var title="">secure</var> to
-      true.</p>
+       <li><p><span>Parse a Web Socket URL's components</span> from
+       the <var title="">url</var> argument, to obtain new values for
+       <var title="">host</var>, <var title="">port</var>, <var
+       title="">resource name</var>, and <var
+       title="">secure</var>. If this fails, <span>fail the Web Socket
+       connection</span> and abort these steps.</p></li>
 
-      <p>Let <var title="">host</var> be the value of the <span
-      title="url-host"><host></span> component of <var
-      title="">url</var>, <span>converted to ASCII
-      lowercase</span>.</p>
+       <li><p>If <var title="">was secure</var> is true but <var
+       title="">secure</var> is now false, <span>fail the Web Socket
+       connection</span> and abort these steps.</p></li>
 
-      <p>If <var title="">url</var> has a <span
-      title="url-port"><port></span> component, then let <var
-      title="">port</var> be that component's value; otherwise, there
-      is no explicit <var title="">port</var>.</p>
+       <li><p>If <var title="">port</var> is a port to which the user
+       agent is configured to block access, then <span>fail the Web
+       Socket connection</span> and abort these steps. (User agents
+       typically block access to well-known ports like SMTP.)</p></li>
+       <!--
+        e.g. http://www.mozilla.org/projects/netlib/PortBanning.html
+       -->
 
-      <p>If there is an explicit <var title="">port</var> and the user
-      agent is configured to block access to that port, then
-      <span>fail the Web Socket connection</span> and abort these
-      steps.</p>
+       <li><p>Close the connection if the server has not already done
+       so.</p></li>
 
-      <p>Let <var title="">resource name</var> be the value of the
-      <span title="url-path"><path></span> component (which
-      might be empty) of <var title="">url</var>.</p>
+       <li><p>Jump back to the first step of the overall algorithm
+       (the very top of the handshake).</p></li>
 
-      <p>If <var title="">resource name</var> is the empty string, set
-      it to a single character U+002F SOLIDUS (/).</p>
+      </ol>
 
-      <p>If <var title="">url</var> has a <span
-      title="url-query"><query></span> component, then append a
-      single U+003F QUESTION MARK (?) character to <var
-      title="">resource name</var>, followed by the value of the <span
-      title="url-query"><query></span> component.</p>
-
-      <p>Close the connection if the server has not already done
-      so.</p>
-
-      <p>Jump back to the first step of this algorithm.</p>
-
      </dd>
 
 
@@ -71873,6 +71884,9 @@
 
   <h6>Registration of ws: scheme</h6>
 
+  <p>A <code title="">ws:</code> URL identifies a Web Socket server
+  and resource name.</p>
+
   <dl>
 
    <dt>URI scheme name.</dt>
@@ -71882,7 +71896,10 @@
    <dd>Permanent.</dd>
 
    <dt>URI scheme syntax.</dt>
-   <dd>"ws" ":" hier-part [ "?" query ]</dd>
+   <dd>
+    <p>In ABNF terms using the terminals from the IRI specifications: <a href="#refsRFC5238">[RFC5238]</a> <a href="#refsRFC3987">[RFC3987]</a></p>
+    <pre>"ws" ":" ihier-part [ "?" iquery ]</pre>
+   </dd>
 
    <dt>URI scheme semantics.</dt>
    <dd>The only operation for this scheme is to open a connection
@@ -71914,6 +71931,10 @@
 
   <h6>Registration of wss: scheme</h6>
 
+  <p>A <code title="">wss:</code> URL identifies a Web Socket server
+  and resource name, and indicates that traffic over that connection
+  is to be encrypted.</p>
+
   <dl>
 
    <dt>URI scheme name.</dt>
@@ -71923,7 +71944,10 @@
    <dd>Permanent.</dd>
 
    <dt>URI scheme syntax.</dt>
-   <dd>"wss" ":" hier-part [ "?" query ]</dd>
+   <dd>
+    <p>In ABNF terms using the terminals from the IRI specifications: <a href="#refsRFC5238">[RFC5238]</a> <a href="#refsRFC3987">[RFC3987]</a></p>
+    <pre>"ws" ":" ihier-part [ "?" iquery ]</pre>
+   </dd>
 
    <dt>URI scheme semantics.</dt>
    <dd>The only operation for this scheme is to open a connection




More information about the Commit-Watchers mailing list