Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const LONG_RESPONSE = 30000;

const clients = new Map();

const receiveBody = async req => new Promise(resolve => {
const receiveBody = async req => {
const buffers = [];
req.on('data', chunk => {
for await (const chunk of req) {
buffers.push(chunk);
}).on('end', () => {
resolve(Buffer.concat(buffers).toString());
});
});
}
return Buffer.concat(buffers).toString();
};


const closeClients = () => {
for (const [connection, client] of clients.entries()) {
Expand Down Expand Up @@ -56,6 +56,8 @@ const listener = (req, res) => {
}
receiveBody(req).then(data => {
client.message(data);
}, err => {
client.error(500, err);
});
} else {
if (url === '/' && !req.connection.encrypted) {
Expand Down