aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-css-plugin/src/test/resources/mock-start-server/failedClose.js
blob: 3c0039e7c2935014b89d92d5b6506df22f316c26 (plain)
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
27
28
#!/usr/bin/env node

const http = require('http');
const port = process.argv[2];

const requestHandler = (request, response) => {
    let data = [];
    request.on('data', chunk => {
        data.push(chunk);
    });
    if (request.url === '/status') {
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.end('OK!');
    } else {
        throw "Failure";
    }
};

const server = http.createServer(requestHandler);

server.listen(port, (err) => {
    if (err) {
        return console.log('something bad happened', err)
    }

    console.log(`server is listening on ${port}`)
});