Skip to content

Commit 57035a5

Browse files
committed
fix ssl mode test that assume the stream will end after the response is completed
1 parent baa4a83 commit 57035a5

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

test/client-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('SPDY Client', function () {
112112
assert.strictEqual(res.statusCode, 200)
113113
assert.strictEqual(res.headers.post, 'headers')
114114

115-
fixtures.expectData(res, 'post body', done)
115+
fixtures.expectData(res, 'post body', done, plain)
116116
})
117117

118118
agent._spdyState.socket.once(plain ? 'connect' : 'secureConnect',

test/fixtures.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,21 @@ exports.keys = {
5252
'-----END CERTIFICATE-----'
5353
}
5454

55-
function expectData (stream, expected, callback) {
55+
function expectData (stream, expected, callback, plain) {
5656
var actual = ''
5757

5858
stream.on('data', function (chunk) {
5959
actual += chunk
60+
// early terminate the test because the stream in ssl mode will not end
61+
// this allows streaming further request with the same network resource
62+
if (!plain && actual === expected) {
63+
callback()
64+
}
6065
})
6166
stream.on('end', function () {
67+
if (!plain) {
68+
return
69+
}
6270
assert.strictEqual(actual, expected)
6371
callback()
6472
})

test/server-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ describe('SPDY Server', function () {
360360
stream.on('response', function (status, headers) {
361361
assert.strictEqual(status, 200)
362362

363-
fixtures.expectData(stream, 'hello world, what\'s up?', done)
363+
fixtures.expectData(stream, 'hello world, what\'s up?', done, plain)
364364
})
365365

366366
stream.end()

0 commit comments

Comments
 (0)