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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial