-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adpater http/2 agent on diagnosticsChannel
- Loading branch information
Showing
2 changed files
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { strict as assert } from 'node:assert'; | ||
import { describe, it, beforeAll, afterAll } from 'vitest'; | ||
import setup from 'proxy'; | ||
import { request, ProxyAgent, getGlobalDispatcher, setGlobalDispatcher } from '../src'; | ||
import { request, ProxyAgent, getGlobalDispatcher, setGlobalDispatcher, Agent } from '../src'; | ||
import { startServer } from './fixtures/server'; | ||
|
||
describe('options.dispatcher.test.ts', () => { | ||
|
@@ -62,4 +62,19 @@ describe('options.dispatcher.test.ts', () => { | |
assert.equal(response.data, '<h1>hello</h1>'); | ||
setGlobalDispatcher(agent); | ||
}); | ||
|
||
it('should work with http/2 dispatcher', async () => { | ||
// https://github.com/nodejs/undici/issues/2750#issuecomment-1941009554 | ||
const agent = new Agent({ | ||
allowH2: true, | ||
}); | ||
assert(agent); | ||
const response = await request('https://registry.npmmirror.com', { | ||
Check failure Code scanning / CodeQL Hard-coded credentials Critical test
The hard-coded value "https://registry.npmmirror.com" is used as
authorization header Error loading related location Loading |
||
dataType: 'json', | ||
timing: true, | ||
dispatcher: agent, | ||
}); | ||
assert.equal(response.status, 200); | ||
assert.equal(response.headers['content-type'], 'application/json; charset=utf-8'); | ||
}); | ||
}); |