-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use keep alive connections (#166)
* chore: replace cross-fetch by node-fetch * feat: use keep-alive connections
- Loading branch information
Showing
8 changed files
with
70 additions
and
20 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
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { fetchWithKeepAlive } from '../../../src/helpers/utils'; | ||
import fetch from 'node-fetch'; | ||
|
||
describe('utils.ts', () => { | ||
describe('fetchWithKeepAlive', () => { | ||
const TEST_URL = 'https://snapshot.org'; | ||
|
||
it('set the custom agent with keep-alive', async () => { | ||
const response = await fetchWithKeepAlive(TEST_URL); | ||
expect(response.headers.get('connection')).toEqual('keep-alive'); | ||
}); | ||
|
||
it('does not use a keep-alive connection with default node-fetch', async () => { | ||
const response = await fetch(TEST_URL); | ||
expect(response.headers.get('connection')).toEqual('close'); | ||
}); | ||
}); | ||
}); |
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