forked from KTH-LangSec/server-side-prototype-pollution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp-server.js
More file actions
26 lines (22 loc) · 768 Bytes
/
http-server.js
File metadata and controls
26 lines (22 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const http = require('http');
const server = http.createServer((req, res) => {
console.log('Received request:');
console.log('Method:', req.method);
console.log('URL:', req.url);
console.log('Headers:', req.headers);
// Collecting request body data
let body = [];
req.on('data', chunk => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
console.log('Body:', body);
console.log('==========================================================');
// Sending response
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Request received and logged.');
});
});
server.listen(3000, () => {
console.log('Server running on port 3000');
});