| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9edd342 commit 22d4ed2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var http = require('http'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const http = require('http'); | ||
| 5 | 5 | ||
| 6 | 6 | // Verify that ServerResponse.writeHead() works as setHeader. | |
| 7 | 7 | // Issue 5036 on github. | |
| 8 | 8 | ||
| 9 | - var s = http.createServer(function(req, res) { | ||
| 9 | + const s = http.createServer(common.mustCall((req, res) => { | ||
| 10 | 10 | res.setHeader('test', '1'); | |
| 11 | 11 | ||
| 12 | 12 | // toLowerCase() is used on the name argument, so it must be a string. | |
@@ -31,18 +31,23 @@ var s = http.createServer(function(req, res) { | |||
| 31 | 31 | assert.ok(threw, 'Undefined value should throw'); | |
| 32 | 32 | ||
| 33 | 33 | res.writeHead(200, { Test: '2' }); | |
| 34 | + | ||
| 35 | + assert.throws(() => { | ||
| 36 | + res.writeHead(100, {}); | ||
| 37 | + }, /^Error: Can't render headers after they are sent to the client$/); | ||
| 38 | + | ||
| 34 | 39 | res.end(); | |
| 35 | - }); | ||
| 40 | + })); | ||
| 36 | 41 | ||
| 37 | - s.listen(0, runTest); | ||
| 42 | + s.listen(0, common.mustCall(runTest)); | ||
| 38 | 43 | ||
| 39 | 44 | function runTest() { | |
| 40 | - http.get({ port: this.address().port }, function(response) { | ||
| 41 | - response.on('end', function() { | ||
| 42 | - assert.equal(response.headers['test'], '2'); | ||
| 45 | + http.get({ port: this.address().port }, common.mustCall((response) => { | ||
| 46 | + response.on('end', common.mustCall(() => { | ||
| 47 | + assert.strictEqual(response.headers['test'], '2'); | ||
| 43 | 48 | assert.notStrictEqual(response.rawHeaders.indexOf('Test'), -1); | |
| 44 | 49 | s.close(); | |
| 45 | - }); | ||
| 50 | + })); | ||
| 46 | 51 | response.resume(); | |
| 47 | - }); | ||
| 52 | + })); | ||
| 48 | 53 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments