Bug 1355277 - change h2 origin frame codepoint to 0xc r=nwgh draft
authorPatrick McManus <mcmanus@ducksong.com>
Mon, 10 Apr 2017 21:47:07 -0400
changeset 560584 bd13754e7f9ded6e19cdcf1ae4b0742eb1f9f9ac
parent 560035 b5b5dbed1c409d96aa6b97f2036cd66312fc45ad
child 623740 4df60a345511ddcfba1cb2d47f6c6847be6fd098
push id53463
push userbmo:mcmanus@ducksong.com
push dateTue, 11 Apr 2017 16:34:06 +0000
reviewersnwgh
bugs1355277
milestone55.0a1
Bug 1355277 - change h2 origin frame codepoint to 0xc r=nwgh MozReview-Commit-ID: GPEEmWQOxQ4
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Session.h
testing/xpcshell/node-http2/lib/protocol/framer.js
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -221,17 +221,18 @@ static Http2ControlFx sControlFunctions[
   Http2Session::RecvRstStream,
   Http2Session::RecvSettings,
   Http2Session::RecvPushPromise,
   Http2Session::RecvPing,
   Http2Session::RecvGoAway,
   Http2Session::RecvWindowUpdate,
   Http2Session::RecvContinuation,
   Http2Session::RecvAltSvc, // extension for type 0x0A
-  Http2Session::RecvOrigin  // extension for type 0x0B
+  Http2Session::RecvUnused, // 0x0B was BLOCKED still radioactive
+  Http2Session::RecvOrigin  // extension for type 0x0C
 };
 
 bool
 Http2Session::RoomForMoreConcurrent()
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   return (mConcurrent < mMaxConcurrent);
 }
@@ -2301,16 +2302,25 @@ Http2Session::Received421(nsHttpConnecti
 
   nsAutoCString key(ci->GetOrigin());
   key.Append(':');
   key.AppendInt(ci->OriginPort());
   mOriginFrame.Remove(key);
   LOG3(("Http2Session::Received421 %p key %s removed\n", this, key.get()));
 }
 
+nsresult
+Http2Session::RecvUnused(Http2Session *self)
+{
+  LOG3(("Http2Session %p unknown frame type %x ignored\n",
+        self, self->mInputFrameType));
+  self->ResetDownstreamState();
+  return NS_OK;
+}
+
 // defined as an http2 extension - origin
 // defines receipt of frame type 0x0b.. http://httpwg.org/http-extensions/origin-frame.html
 // as this is an extension, never generate protocol error - just ignore problems
 nsresult
 Http2Session::RecvOrigin(Http2Session *self)
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   MOZ_ASSERT(self->mInputFrameType == FRAME_TYPE_ORIGIN);
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -86,18 +86,19 @@ public:
     FRAME_TYPE_RST_STREAM    = 0x3,
     FRAME_TYPE_SETTINGS      = 0x4,
     FRAME_TYPE_PUSH_PROMISE  = 0x5,
     FRAME_TYPE_PING          = 0x6,
     FRAME_TYPE_GOAWAY        = 0x7,
     FRAME_TYPE_WINDOW_UPDATE = 0x8,
     FRAME_TYPE_CONTINUATION  = 0x9,
     FRAME_TYPE_ALTSVC        = 0xA,
-    FRAME_TYPE_ORIGIN        = 0xB,
-    FRAME_TYPE_LAST          = 0xC
+    FRAME_TYPE_UNUSED        = 0xB,
+    FRAME_TYPE_ORIGIN        = 0xC,
+    FRAME_TYPE_LAST          = 0xD
   };
 
   // NO_ERROR is a macro defined on windows, so we'll name the HTTP2 goaway
   // code NO_ERROR to be NO_HTTP_ERROR
   enum errorType {
     NO_HTTP_ERROR = 0,
     PROTOCOL_ERROR = 1,
     INTERNAL_ERROR = 2,
@@ -183,16 +184,17 @@ public:
   static nsresult RecvRstStream(Http2Session *);
   static nsresult RecvSettings(Http2Session *);
   static nsresult RecvPushPromise(Http2Session *);
   static nsresult RecvPing(Http2Session *);
   static nsresult RecvGoAway(Http2Session *);
   static nsresult RecvWindowUpdate(Http2Session *);
   static nsresult RecvContinuation(Http2Session *);
   static nsresult RecvAltSvc(Http2Session *);
+  static nsresult RecvUnused(Http2Session *);
   static nsresult RecvOrigin(Http2Session *);
 
   char       *EnsureOutputBuffer(uint32_t needed);
 
   template<typename charType>
   void CreateFrameHeader(charType dest, uint16_t frameLength,
                          uint8_t frameType, uint8_t frameFlags,
                          uint32_t streamID);
--- a/testing/xpcshell/node-http2/lib/protocol/framer.js
+++ b/testing/xpcshell/node-http2/lib/protocol/framer.js
@@ -1064,17 +1064,20 @@ Deserializer.ALTSVC = function readAltSv
       frame.port = parseInt(hostport[1], 10);
     } else if (chosenAltSvc[i].name == 'ma') {
       frame.maxAge = parseInt(chosenAltSvc[i].value, 10);
     }
     // Otherwise, we just ignore this
   }
 };
 
-frameTypes[0xB] = 'ORIGIN';
+// frame 0xB was BLOCKED and some versions of chrome will
+// throw PROTOCOL_ERROR upon seeing it with non 0 payload
+
+frameTypes[0xC] = 'ORIGIN';
 frameFlags.ORIGIN = [];
 typeSpecificAttributes.ORIGIN = ['originList'];
 
 Serializer.ORIGIN = function writeOrigin(frame, buffers) {
   for (var i = 0; i < frame.originList.length; i++) {
     var buffer = new Buffer(2);
     buffer.writeUInt16BE(frame.originList[i].length, 0);
     buffers.push(buffer);