-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfetch-head.js
40 lines (35 loc) · 870 Bytes
/
fetch-head.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Use either:
* NODE_OPTIONS=--use-openssl-ca
* or
* node --use-openssl-ca node-fetch/fetch-head.js
*/
import { Agent } from "undici"
import { readFileSync } from 'fs'
const ca = readFileSync("certs/ca.crt")
const cert = readFileSync("certs/ghost-node.fumlersoft.dk.crt")
const key = readFileSync("certs/ghost-node.fumlersoft.dk.key")
const agent = new Agent({
connect: {
cert: cert,
key: key,
ca: ca
}
})
const fetch1 = async () => {
const res = await fetch('https://ns1.fumlersoft.dk/earth-64x64.png', {
method: 'HEAD',
dispatcher: agent
})
console.log('fetch1:', res)
}
const fetch2 = async () => {
const res = await fetch('https://ns2.fumlersoft.dk/earth-64x64.png', {
method: 'HEAD',
dispatcher: agent
})
console.log('fetch2:', res)
}
await fetch1()
console.log('==========================')
await fetch2()