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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5e5581eeba07
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 };
15
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 }
22
23 return header;
24 };

mercurial