mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-13 07:53:20 -05:00
Web relay can now stream chunk encoding towards relay device, #4172
This commit is contained in:
parent
e351e839db
commit
d1e0cd94e2
12
apprelays.js
12
apprelays.js
@ -198,16 +198,16 @@ module.exports.CreateWebRelay = function (parent, db, args, domain) {
|
|||||||
request += '\r\n';
|
request += '\r\n';
|
||||||
|
|
||||||
if (req.headers['content-length'] != null) {
|
if (req.headers['content-length'] != null) {
|
||||||
// Stream the HTTP request and body, this is a content-length HTTP request, just forward the body dataf
|
// Stream the HTTP request and body, this is a content-length HTTP request, just forward the body data
|
||||||
send(Buffer.from(request));
|
send(Buffer.from(request));
|
||||||
req.on('data', function (data) { send(data); }); // TODO: Flow control (Not sure how to do this in ExpressJS)
|
req.on('data', function (data) { send(data); }); // TODO: Flow control (Not sure how to do this in ExpressJS)
|
||||||
req.on('end', function () { });
|
req.on('end', function () { });
|
||||||
} else if (req.headers['transfer-encoding'] != null) {
|
} else if (req.headers['transfer-encoding'] != null) {
|
||||||
// Read the HTTP body and send the request to the device
|
// Stream the HTTP request and body, this is a chunked encoded HTTP request
|
||||||
console.log('chunk stream start');
|
// TODO: Flow control (Not sure how to do this in ExpressJS)
|
||||||
obj.requestBinary = [Buffer.from(request)];
|
send(Buffer.from(request));
|
||||||
req.on('data', function (data) { console.log('chunk stream data'); obj.requestBinary.push(data); });
|
req.on('data', function (data) { send(Buffer.concat([Buffer.from(data.length.toString(16) + '\r\n', 'binary'), data, send(Buffer.from('\r\n', 'binary'))])); });
|
||||||
req.on('end', function () { console.log('chunk stream end');send(Buffer.concat(obj.requestBinary)); delete obj.requestBinary; });
|
req.on('end', function () { send(Buffer.from('0\r\n\r\n', 'binary')); });
|
||||||
} else {
|
} else {
|
||||||
// Request has no body, send it now
|
// Request has no body, send it now
|
||||||
send(Buffer.from(request));
|
send(Buffer.from(request));
|
||||||
|
Loading…
Reference in New Issue
Block a user