<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12912</bug_id>
          
          <creation_ts>2011-06-08 17:17:20 +0000</creation_ts>
          <short_desc>Close status code is an unsigned short</short_desc>
          <delta_ts>2011-06-22 01:30:22 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebSocket API (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Bateman [MSFT]">adrianba</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>cam</cc>
    
    <cc>ian</cc>
    
    <cc>ifette</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>49324</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-06-08 17:17:20 +0000</bug_when>
    <thetext>The code argument to the close() method [1] should be an unsigned short to match the protocol spec [2]. This should also be reflected in the CloseEvent [3].

The protocol document says:

      If there is a body, the first two bytes of the body
      MUST be a 2-byte integer (in network byte order)
      representing a status code defined in Section 7.4.


[1] http://dev.w3.org/html5/websockets/#the-websocket-interface
[2] http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07#section-4.5.1
[3] http://dev.w3.org/html5/websockets/#closeevent</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50066</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-06-21 22:40:35 +0000</bug_when>
    <thetext>Why should 65535 throw INVALID_ACCESS_ERR but 66535 send the code 1000? I guess one could ask the same of why 4294967295 should throw INVALID_ACCESS_ERR when 4294968295 sends the code 1000... Maybe the solution is to add [Clamp] to the interface.

I&apos;ve changed it to &apos;unsigned short&apos; with [Clamp].

cc&apos;ing heycam for sanity check.

(Note that this makes the CloseEvent interface less useful, since anyone reusing it now is limited to 2**16 codes instead of 2**32, but I guess that&apos;s not a big deal.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50067</commentid>
    <comment_count>2</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-06-21 22:42:11 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r6268.
Check-in comment: WebSocket close code can fit in an unsigned short, so use that instead.
http://html5.org/tools/web-apps-tracker?from=6267&amp;to=6268</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50085</commentid>
    <comment_count>3</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-06-21 23:53:41 +0000</bug_when>
    <thetext>(Not being overly familiar with the Web Sockets protocol: is the 2-byte integer closing code meant to be signed or unsigned?  All other instances of the word &quot;integer&quot; in the Internet-Draft are prefaced with &quot;unsigned&quot;, so does that mean the bare &quot;integer&quot; for the code means it is signed?)

I introduced [Clamp] in Web IDL to resolve the situation where for compatibility reasons, the way that JS Number values are converted into octets on CanvasPixelArray needed to be different from the default.  I don&apos;t see why close() needs different conversion behaviour from the default that Web IDL uses.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50097</commentid>
    <comment_count>4</comment_count>
    <who name="Ian Fette [Google]">ifette</who>
    <bug_when>2011-06-22 01:30:22 +0000</bug_when>
    <thetext>Bug in the protocol. It should say &quot;unsigned&quot; in the protocol. I will fix that.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>