* Builds the options object for fetch * @returns {object} Options object containing headers (and dispatcher if needed)
()
| 137 | * @returns {object} Options object containing headers (and dispatcher if needed) |
| 138 | */ |
| 139 | getRequestOptions () { |
| 140 | const headers = { |
| 141 | "User-Agent": getUserAgent(), |
| 142 | ...this.customHeaders |
| 143 | }; |
| 144 | const options = { headers }; |
| 145 | |
| 146 | if (this.selfSignedCert) { |
| 147 | options.dispatcher = new Agent({ |
| 148 | connect: { |
| 149 | rejectUnauthorized: false |
| 150 | } |
| 151 | }); |
| 152 | } |
| 153 | |
| 154 | if (this.auth) { |
| 155 | if (this.auth.method === "bearer") { |
| 156 | headers.Authorization = `Bearer ${this.auth.pass}`; |
| 157 | } else { |
| 158 | headers.Authorization = `Basic ${Buffer.from(`${this.auth.user}:${this.auth.pass}`).toString("base64")}`; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | return options; |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Parses the Retry-After header value |
no test coverage detected