(type)
| 236 | errorAndPipelining(consts.ASYNC_ITERATOR) |
| 237 | |
| 238 | function errorAndChunkedEncodingPipelining (type) { |
| 239 | test(`POST with chunked encoding, ${type} body that errors and pipelining 1 should reconnect`, async (t) => { |
| 240 | const trackPostWithPlan = type !== consts.STREAM |
| 241 | const p = tspl(t, { plan: trackPostWithPlan ? 12 : 8 }) |
| 242 | |
| 243 | const server = createServer({ joinDuplicateHeaders: true }) |
| 244 | installErrorAndReconnectServer(server, p, { |
| 245 | contentLength: undefined, |
| 246 | trackPostWithPlan |
| 247 | }) |
| 248 | t.after(closeServerAsPromise(server)) |
| 249 | |
| 250 | server.listen(0, () => { |
| 251 | const client = new Client(`http://localhost:${server.address().port}`) |
| 252 | t.after(client.destroy.bind(client)) |
| 253 | |
| 254 | client.request({ |
| 255 | path: '/', |
| 256 | method: 'POST', |
| 257 | opaque: 'asd', |
| 258 | body: maybeWrapStream(new Readable({ |
| 259 | read () { |
| 260 | this.push('a string') |
| 261 | this.destroy(new Error('kaboom')) |
| 262 | } |
| 263 | }), type) |
| 264 | }, (err, data) => { |
| 265 | p.strictEqual(err.message, 'kaboom') |
| 266 | p.strictEqual(data.opaque, 'asd') |
| 267 | }) |
| 268 | |
| 269 | // this will be queued up |
| 270 | client.request({ path: '/', method: 'GET' }, (err, { statusCode, headers, body }) => { |
| 271 | p.ifError(err) |
| 272 | p.strictEqual(statusCode, 200) |
| 273 | p.strictEqual(headers['content-type'], 'text/plain') |
| 274 | const bufs = [] |
| 275 | body.on('data', (buf) => { |
| 276 | bufs.push(buf) |
| 277 | }) |
| 278 | body.on('end', () => { |
| 279 | p.strictEqual('hello', Buffer.concat(bufs).toString('utf8')) |
| 280 | }) |
| 281 | }) |
| 282 | }) |
| 283 | await p.completed |
| 284 | }) |
| 285 | } |
| 286 | |
| 287 | errorAndChunkedEncodingPipelining(consts.STREAM) |
| 288 | errorAndChunkedEncodingPipelining(consts.ASYNC_ITERATOR) |
no test coverage detected
searching dependent graphs…