Not sure how much of this is mocked as part of this library, but I noticed that the complete property on the response to a http request remains false, even after the entire reply message is received by the client (data and end events handled). E.g.:
nock('http://test.com')
.replyDate()
.defaultReplyHeaders({
'Content-Type': 'application/text',
'Content-Length': function(req, res, body) { return body.length; },
})
.get('/testFile.txt')
.reply(200, Buffer.from(new Array(10000).fill('a')));
http.request({
method: 'GET',
url: 'http://test.com/testFile.txt'
host: 'test.com',
path: '/testFile.txt'
}, function(response) {
const data = []
response.on('data', function(chunk) { data.push(chunk); });
response.on('end', function() {
if (!response.complete) {
console.log('Connection terminated while the message was being sent'); // <-- The case with nock
} else {
console.log('Entire message received');
}
});
});
Not sure how much of this is mocked as part of this library, but I noticed that the
completeproperty on the response to a http request remains false, even after the entire reply message is received by the client (dataandendevents handled). E.g.: