summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-contentLength0.js
blob: 537c7c0691af16a6029113684e05787f965876c3 (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
'use strict';
require('../common');
const http = require('http');

// Simple test of Node's HTTP Client choking on a response
// with a 'Content-Length: 0 ' response header.
// I.E. a space character after the 'Content-Length' throws an `error` event.


const s = http.createServer(function(req, res) {
  res.writeHead(200, {'Content-Length': '0 '});
  res.end();
});
s.listen(0, function() {

  const request =
      http.request({ port: this.address().port }, function(response) {
        console.log('STATUS: ' + response.statusCode);
        s.close();
        response.resume();
      });

  request.end();
});