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
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 | }; |