Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added setGlobalDispatcher and getGlobalDispatcher to the node.js bundle
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Apr 23, 2024
commit 7b70e6ec5d7d7c798308e6f5b7e5ce09f3447169
3 changes: 3 additions & 0 deletions index-fetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global')
const EnvHttpProxyAgent = require('./lib/dispatcher/env-http-proxy-agent')
const fetchImpl = require('./lib/web/fetch').fetch

Expand All @@ -23,3 +24,5 @@ module.exports.EventSource = require('./lib/web/eventsource/eventsource').EventS

// Expose the fetch implementation to be enabled in Node.js core via a flag
module.exports.EnvHttpProxyAgent = EnvHttpProxyAgent
module.exports.getGlobalDispatcher = getGlobalDispatcher
module.exports.setGlobalDispatcher = setGlobalDispatcher
6 changes: 6 additions & 0 deletions test/fetch/export-env-proxy-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ const undiciFetch = require('../../undici-fetch')

test('EnvHttpProxyAgent should be part of Node.js bundle', () => {
assert.strictEqual(typeof undiciFetch.EnvHttpProxyAgent, 'function')
assert.strictEqual(typeof undiciFetch.getGlobalDispatcher, 'function')
assert.strictEqual(typeof undiciFetch.setGlobalDispatcher, 'function')

const agent = new undiciFetch.EnvHttpProxyAgent()
undiciFetch.setGlobalDispatcher(agent)
assert.strictEqual(undiciFetch.getGlobalDispatcher(), agent)
})