fixed timing problem that lead to lost request bodies
This commit is contained in:
parent
68d6322b42
commit
528e58969e
|
@ -50,7 +50,7 @@ module.exports.create = function (deps, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn('failed to identify protocol from first chunk', firstChunk);
|
console.warn('failed to identify protocol from first chunk', firstChunk);
|
||||||
conn.close();
|
conn.destroy();
|
||||||
}
|
}
|
||||||
function netHandler(conn, opts) {
|
function netHandler(conn, opts) {
|
||||||
function getProp(name) {
|
function getProp(name) {
|
||||||
|
|
|
@ -29,12 +29,14 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
|
||||||
function handleChunk(chunk) {
|
function handleChunk(chunk) {
|
||||||
if (!errored) {
|
if (!errored) {
|
||||||
opts.firstChunk = Buffer.concat([opts.firstChunk, chunk]);
|
opts.firstChunk = Buffer.concat([opts.firstChunk, chunk]);
|
||||||
if (opts.firstChunk.includes('\r\n\r\n')) {
|
if (!opts.firstChunk.includes('\r\n\r\n')) {
|
||||||
resolve(opts.firstChunk.toString());
|
|
||||||
conn.removeListener('error', handleErr);
|
|
||||||
} else {
|
|
||||||
conn.once('data', handleChunk);
|
conn.once('data', handleChunk);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
conn.removeListener('error', handleErr);
|
||||||
|
conn.pause();
|
||||||
|
resolve(opts.firstChunk.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn.once('data', handleChunk);
|
conn.once('data', handleChunk);
|
||||||
|
@ -144,6 +146,7 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
|
||||||
// data comes in.
|
// data comes in.
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
conn.unshift(opts.firstChunk);
|
conn.unshift(opts.firstChunk);
|
||||||
|
conn.resume();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convenience return for all the check* functions.
|
// Convenience return for all the check* functions.
|
||||||
|
@ -160,6 +163,7 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
|
||||||
deps.tunnelServer.handleClientConn(conn);
|
deps.tunnelServer.handleClientConn(conn);
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
conn.unshift(opts.firstChunk);
|
conn.unshift(opts.firstChunk);
|
||||||
|
conn.resume();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +215,7 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
|
||||||
deps.tunnelServer.handleAdminConn(conn);
|
deps.tunnelServer.handleAdminConn(conn);
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
conn.unshift(opts.firstChunk);
|
conn.unshift(opts.firstChunk);
|
||||||
|
conn.resume();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue