MCPcopy
hub / github.com/nodejs/undici / writeHeadersStartedWithBody

Function writeHeadersStartedWithBody

test/node-test/abort-controller.js:190–213  ·  view source on GitHub ↗
(body, type)

Source from the content-addressed store, hash-verified

188 waitingWithBody(wrapWithAsyncIterable(createReadStream(__filename)), 'async-iterator')
189
190 function writeHeadersStartedWithBody (body, type) {
191 test(`Abort ${controllerName} while waiting response (write headers started) (with body ${type})`, async (t) => {
192 const p = tspl(t, { plan: 1 })
193
194 const abortController = new AbortControllerImpl()
195 const server = createServer({ joinDuplicateHeaders: true }, (req, res) => {
196 res.writeHead(200, { 'content-type': 'text/plain' })
197 res.flushHeaders()
198 abortController.abort()
199 res.end('hello world')
200 })
201 t.after(closeServerAsPromise(server))
202
203 server.listen(0, () => {
204 const client = new Client(`http://localhost:${server.address().port}`)
205 t.after(client.destroy.bind(client))
206
207 client.request({ path: '/', method: 'POST', body, signal: abortController.signal }, (err, response) => {
208 p.ok(err instanceof errors.RequestAbortedError || err instanceof DOMException)
209 })
210 })
211 await p.completed
212 })
213 }
214
215 writeHeadersStartedWithBody('hello', 'string')
216 writeHeadersStartedWithBody(createReadStream(__filename), 'stream')

Callers 1

Calls 7

createServerFunction · 0.85
closeServerAsPromiseFunction · 0.85
listenMethod · 0.80
okMethod · 0.80
abortMethod · 0.65
endMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…