-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify error code&msg, make client cb be called
- Loading branch information
Showing
2 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
const ClientRequest = require('http').ClientRequest; | ||
|
||
{ | ||
const req = new ClientRequest(() => {}); | ||
req.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ECONNREFUSED'); | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.writeHead(200); | ||
res.end('hello world'); | ||
})).listen(80, '127.0.0.1'); | ||
|
||
const req = new ClientRequest(common.mustCall((response) => { | ||
let body = ''; | ||
response.setEncoding('utf8'); | ||
response.on('data', (chunk) => { | ||
body += chunk; | ||
}); | ||
|
||
response.on('end', common.mustCall(() => { | ||
assert.strictEqual(body, 'hello world'); | ||
server.close(); | ||
})); | ||
})); | ||
assert.strictEqual(req.path, '/'); | ||
assert.strictEqual(req.method, 'GET'); | ||
|
||
req.end(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters