testing/xpcshell/node-spdy/lib/spdy/protocol/generic.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

     1 //
     2 // ### function parseHeader (data)
     3 // ### @data {Buffer} incoming data
     4 // Returns parsed SPDY frame header
     5 //
     6 exports.parseHeader = function parseHeader(data) {
     7   var header = {
     8     control: (data.readUInt8(0) & 0x80) === 0x80 ? true : false,
     9     version: null,
    10     type: null,
    11     id: null,
    12     flags: data.readUInt8(4),
    13     length: data.readUInt32BE(4) & 0x00ffffff
    14   };
    16   if (header.control) {
    17     header.version = data.readUInt16BE(0) & 0x7fff;
    18     header.type = data.readUInt16BE(2);
    19   } else {
    20     header.id = data.readUInt32BE(0) & 0x7fffffff;
    21   }
    23   return header;
    24 };

mercurial