push
travis-ci
60 of 61 branches covered (98.36%)
Branch coverage included in aggregate %.
22 of 22 new or added lines in 2 files covered. (100.0%)
166 of 167 relevant lines covered (99.4%)
67.07 hits per line
|
function parseHeader(header) { |
10✔ |
|
var parts = header.split(' '); |
20✔ |
|
if (parts[0] !== 'PROXY') { |
|
|
throw new Error('PROXY line missing, is haproxy present?'); |
10✔ |
5 |
} |
|
|
return parts[2]; |
10✔ |
7 |
} |
|
8 |
|
|
|
function createParser(socket, connected, headerError) { |
10✔ |
|
var buffer = ''; |
30✔ |
11 |
|
|
|
return function () { |
30✔ |
|
var char; |
20✔ |
14 |
|
|
|
try {
|
20✔ |
|
while (true) { |
20✔ |
|
if ((char = socket.read(1)) === null) { |
|
|
return;
|
× |
19 |
} |
|
|
char = char.toString('ascii'); |
710✔ |
|
if (char === '\n') { |
|
|
break;
|
20✔ |
23 |
} |
|
|
buffer += char;
|
690✔ |
25 |
} |
|
|
connected(parseHeader(buffer)); |
20✔ |
27 |
} catch (e) {
|
|
|
headerError(e); |
10✔ |
29 |
} |
|
30 |
}; |
|
31 |
} |
|
32 |
|
|
|
module.exports = createParser; |
10✔ |