Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 };