-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62dd4ff
commit bc36686
Showing
4 changed files
with
66 additions
and
59 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { Client, errors } = require('..') | ||
const http = require('http') | ||
const EE = require('events') | ||
const { kBusy } = require('../lib/core/symbols') | ||
|
||
// TODO: move to test/node-test/client-connect.js | ||
test('connect aborted after connect', (t) => { | ||
t.plan(3) | ||
|
||
const signal = new EE() | ||
const server = http.createServer((req, res) => { | ||
t.fail() | ||
}) | ||
server.on('connect', (req, c, firstBodyChunk) => { | ||
signal.emit('abort') | ||
}) | ||
t.teardown(server.close.bind(server)) | ||
|
||
server.listen(0, () => { | ||
const client = new Client(`http://localhost:${server.address().port}`, { | ||
pipelining: 3 | ||
}) | ||
t.teardown(client.destroy.bind(client)) | ||
|
||
client.connect({ | ||
path: '/', | ||
signal, | ||
opaque: 'asd' | ||
}, (err, { opaque }) => { | ||
t.equal(opaque, 'asd') | ||
t.type(err, errors.RequestAbortedError) | ||
}) | ||
t.equal(client[kBusy], true) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { Client } = require('..') | ||
const net = require('net') | ||
|
||
// TODO: move to test/node-test/client-connect.js | ||
test('parser error', (t) => { | ||
t.plan(2) | ||
|
||
const server = net.createServer() | ||
server.once('connection', (socket) => { | ||
socket.write('asd\n\r213123') | ||
}) | ||
t.teardown(server.close.bind(server)) | ||
|
||
server.listen(0, () => { | ||
const client = new Client(`http://localhost:${server.address().port}`) | ||
t.teardown(client.destroy.bind(client)) | ||
|
||
client.request({ path: '/', method: 'GET' }, (err) => { | ||
t.ok(err) | ||
client.close((err) => { | ||
t.error(err) | ||
}) | ||
}) | ||
}) | ||
}) |
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
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