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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>81072</bug_id>
          
          <creation_ts>2012-03-13 20:26:56 -0700</creation_ts>
          <short_desc>[WebSocket]Browser should use 1000 as status code when WebSocket API close is called without status code parameter.</short_desc>
          <delta_ts>2012-05-08 00:17:53 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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>0</everconfirmed>
          <reporter name="Li Yin">li.yin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>eric</cc>
    
    <cc>tkent</cc>
    
    <cc>toyoshim</cc>
    
    <cc>yutak</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>578128</commentid>
    <comment_count>0</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-03-13 20:26:56 -0700</bug_when>
    <thetext>When WebSocket API close was called like this &quot;ws.cloes()&quot;, chromium didn&apos;t send the close frame to WebSocket server.
And WebSocket server still sent frame to browser unexpectedly, it didn&apos;t produce some error, but maybe it&apos;s not friendly.

Firefox used the status 1000 as the default value, when the close api had no the parameter.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578129</commentid>
    <comment_count>1</comment_count>
      <attachid>131776</attachid>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-03-13 20:33:25 -0700</bug_when>
    <thetext>Created attachment 131776
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578138</commentid>
    <comment_count>2</comment_count>
      <attachid>131776</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-03-13 21:14:05 -0700</bug_when>
    <thetext>Comment on attachment 131776
Patch

Can you provide a link to the spec that requires this change?  Also, changes in behavior require tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578156</commentid>
    <comment_count>3</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-03-13 21:54:13 -0700</bug_when>
    <thetext>http://dev.w3.org/html5/websockets/#dom-websocket-close
   If the WebSocket closing handshake has not yet been started,
   Start the WebSocket closing handshake and...

Here, from RFC6455 http://tools.ietf.org/html/rfc6455#section-7.4, 
   Start the WebSocket Closing Handshake, should send the close frame.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578163</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-03-13 22:07:43 -0700</bug_when>
    <thetext>Thanks.  That&apos;s good information to include in the ChangeLog.  (The patch still needs a test, of course.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578186</commentid>
    <comment_count>5</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-03-13 23:35:30 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; When WebSocket API close was called like this &quot;ws.cloes()&quot;, chromium didn&apos;t send the close frame to WebSocket server.
&gt; And WebSocket server still sent frame to browser unexpectedly, it didn&apos;t produce some error, but maybe it&apos;s not friendly.
&gt; 

I&apos;m sorry for my previous misleading.
From the newest code, chromium indeed sent close frame, when the close api was called without parameter. 
but it just had no body(status code and reason), which seemed to be allowed by RFC6455.

&gt; Firefox used the status 1000 as the default value, when the close api had no the parameter.

The only difference is that Firefox used normal closure as the default value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>578513</commentid>
    <comment_count>6</comment_count>
    <who name="Takashi Toyoshima">toyoshim</who>
    <bug_when>2012-03-14 10:05:10 -0700</bug_when>
    <thetext>Hi joey, thank you for a patch.
Originally, I implemented this WebSocket::close method for new hybi/rfc protocol.

Before hybi-06, the WebSocket protocol didn&apos;t have the status code and the reason. At that time, the WebSocket API doesn&apos;t allow any argument for close method.
From the viewpoint of protocol and API history, I decided to send close frame with empty body when user call close without any argument.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>607333</commentid>
    <comment_count>7</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-04-22 01:14:07 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Hi joey, thank you for a patch.
&gt; Originally, I implemented this WebSocket::close method for new hybi/rfc protocol.
&gt; 
&gt; Before hybi-06, the WebSocket protocol didn&apos;t have the status code and the reason. At that time, the WebSocket API doesn&apos;t allow any argument for close method.
&gt; From the viewpoint of protocol and API history, I decided to send close frame with empty body when user call close without any argument.

From the bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=16703
It still have no obvious definition about the default status code in the spec, but it seems that 1000 should be.
Do you think it is necessary to use 1000 instead of no status code?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>607476</commentid>
    <comment_count>8</comment_count>
    <who name="Takashi Toyoshima">toyoshim</who>
    <bug_when>2012-04-22 22:39:13 -0700</bug_when>
    <thetext>Hi, Li.

I post a similar comment on the w3c thread, too.

[from RFC6455 7.1.5.]
&gt; a Close control frame may contain a status code indicating a reason for closure.
&gt; (snip)
&gt; If this Close control frame contains no status code, _The WebSocket
&gt; Connection Close Code_ is considered to be 1005.  If _The WebSocket
&gt; Connection is Closed_ and no Close control frame was received by the
&gt; endpoint (such as could occur if the underlying transport connection
&gt; is lost), _The WebSocket Connection Close Code_ is considered to be
&gt; 1006.

Actually, RFC said code and reason are optional. It uses &apos;MAY&apos; in normative sections. I understand that this is because the API allow to omit them. As a result, pseudo code 1005 is needed for representing this case. 1005 doesn&apos;t represent any unexpected or error case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>618369</commentid>
    <comment_count>9</comment_count>
    <who name="Takashi Toyoshima">toyoshim</who>
    <bug_when>2012-05-07 23:59:49 -0700</bug_when>
    <thetext>API spec author said in the w3c thread in https://www.w3.org/Bugs/Public/show_bug.cgi?id=16703,

&gt; Ian &apos;Hixie&apos; Hickson 2012-05-02 20:09:29 UTC
&gt; As far as I can tell, the spec is clear on this. If there&apos;s no argument, then
&gt; no close code is passed to the protocol. The protocol spec defines what to do
&gt; in that case.

And Firefox is going to fix the behavior.
https://bugzilla.mozilla.org/show_bug.cgi?id=748580

So, I&apos;d like to close this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>618379</commentid>
    <comment_count>10</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-05-08 00:17:53 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; API spec author said in the w3c thread in https://www.w3.org/Bugs/Public/show_bug.cgi?id=16703,
&gt; 
&gt; &gt; Ian &apos;Hixie&apos; Hickson 2012-05-02 20:09:29 UTC
&gt; &gt; As far as I can tell, the spec is clear on this. If there&apos;s no argument, then
&gt; &gt; no close code is passed to the protocol. The protocol spec defines what to do
&gt; &gt; in that case.
&gt; 
&gt; And Firefox is going to fix the behavior.
&gt; https://bugzilla.mozilla.org/show_bug.cgi?id=748580
&gt; 
&gt; So, I&apos;d like to close this issue.

Okay, thanks.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>131776</attachid>
            <date>2012-03-13 20:33:25 -0700</date>
            <delta_ts>2012-03-13 21:14:05 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-81072-20120315113515.patch</filename>
            <type>text/plain</type>
            <size>2473</size>
            <attacher name="Li Yin">li.yin</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZp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TsKICAgICBTdHJpbmcgcmVhc29uID0g
IiI7CiAgICAgaWYgKGFyZ3VtZW50Q291bnQgPj0gMSkgewogICAgICAgICBkb3VibGUgeCA9IGFy
Z3NbMF0tPk51bWJlclZhbHVlKCk7Cg==
</data>
<flag name="review"
          id="135197"
          type_id="1"
          status="-"
          setter="abarth"
    />
          </attachment>
      

    </bug>

</bugzilla>