summaryrefslogtreecommitdiffhomepage
path: root/test/node/variables/app.js
blob: 968afba5f3cece3c7cc697c1bd588a99cd49884b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env node

require('unit-http').createServer(function (req, res) {
    let body = '';
    req.on('data', chunk => {
        body += chunk.toString();
    });
    req.on('end', () => {
        res.setHeader('Request-Method', req.method);
        res.setHeader('Request-Uri', req.url);
        res.setHeader('Server-Protocol', req.httpVersion);
        res.setHeader('Request-Raw-Headers', req.rawHeaders.join());
        res.setHeader('Content-Length', Buffer.byteLength(body));
        res.setHeader('Content-Type', req.headers['Content-Type']);
        res.setHeader('Custom-Header', req.headers['Custom-Header']);
        res.setHeader('Http-Host', req.headers['Host']);
        res.writeHead(200, {});
        res.end(body);
    });
}).listen(7080);