summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-hex-write.js
blob: adfe18077a8259ca9669ce730db392900fd91e97 (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
'use strict';
const common = require('../common');
var assert = require('assert');

var http = require('http');

var expect = 'hex\nutf8\n';

http.createServer(function(q, s) {
  s.setHeader('content-length', expect.length);
  s.write('6865780a', 'hex');
  s.write('utf8\n');
  s.end();
  this.close();
}).listen(0, common.mustCall(function() {
  http.request({ port: this.address().port })
    .on('response', common.mustCall(function(res) {
      var data = '';

      res.setEncoding('ascii');
      res.on('data', function(c) {
        data += c;
      });
      res.on('end', common.mustCall(function() {
        assert.strictEqual(data, expect);
      }));
    })).end();
}));