MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / getRequestOptions

Method getRequestOptions

js/http_fetcher.js:139–163  ·  view source on GitHub ↗

* Builds the options object for fetch * @returns {object} Options object containing headers (and dispatcher if needed)

()

Source from the content-addressed store, hash-verified

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

Callers 2

fetchMethod · 0.95

Calls 1

getUserAgentFunction · 0.85

Tested by

no test coverage detected