Bug 748580: Do not reply to server close with 1005/1006/1015 as close code. r=smaug
☠☠ backed out by c90a07a9c025 ☠ ☠
authorJason Duell <jduell.mcbugs@gmail.com>
Wed, 16 May 2012 17:05:06 -0700
changeset 94159 c567e28272d5257cdffee91ccd91c6e611478c42
parent 94158 deb1fd74e10b5d129081ca5dab8defec05e64403
child 94160 c90a07a9c0254a04809e35e0d8364ca198107838
push id9499
push userjduell@mozilla.com
push dateThu, 17 May 2012 00:05:27 +0000
treeherdermozilla-inbound@c567e28272d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs748580
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 748580: Do not reply to server close with 1005/1006/1015 as close code. r=smaug
content/base/src/nsWebSocket.cpp
--- a/content/base/src/nsWebSocket.cpp
+++ b/content/base/src/nsWebSocket.cpp
@@ -385,20 +385,24 @@ nsWebSocket::OnServerClose(nsISupports *
     return NS_ERROR_UNEXPECTED;
   }
 
   // store code/string for onclose DOM event
   mCloseEventCode = aCode;
   CopyUTF8toUTF16(aReason, mCloseEventReason);
 
   if (mReadyState == nsIWebSocket::OPEN) {
-    // Send reciprocal Close frame.
-    // 5.5.1: "When sending a Close frame in response, the endpoint typically
-    // echos the status code it received"
-    CloseConnection(aCode, aReason);
+    // RFC 6455, 5.5.1: "When sending a Close frame in response, the endpoint
+    // typically echos the status code it received".
+    // But never send certain codes, per section 7.4.1
+    if (aCode == 1005 || aCode == 1006 || aCode == 1015) {
+      CloseConnection(0, EmptyCString());
+    } else {
+      CloseConnection(aCode, aReason);
+    }
   } else {
     // Nothing else to do: OnStop does the rest of the work.
     NS_ASSERTION (mReadyState == nsIWebSocket::CLOSING, "unknown state");
     NS_ASSERTION(!mDisconnected, "should not be disconnected during CLOSING");
   }
 
   return NS_OK;
 }