MCPcopy
hub / github.com/CodebuffAI/codebuff / httpGet

Function httpGet

freebuff/cli/release/http.js:144–166  ·  view source on GitHub ↗
(url, options = {})

Source from the content-addressed store, hash-verified

142 }
143
144 async function httpGet(url, options = {}) {
145 const reqOptions = await buildRequestOptions(url, options)
146
147 return new Promise((resolve, reject) => {
148 const req = httpsModule.get(reqOptions, (res) => {
149 if (res.statusCode === 301 || res.statusCode === 302) {
150 res.resume()
151 httpGet(new URL(res.headers.location, url).href, options)
152 .then(resolve)
153 .catch(reject)
154 return
155 }
156
157 resolve(res)
158 })
159
160 req.on('error', reject)
161 req.setTimeout(options.timeout || requestTimeout, () => {
162 req.destroy()
163 reject(new Error('Request timeout.'))
164 })
165 })
166 }
167
168 return {
169 getProxyUrl,

Callers 2

getLatestVersionFunction · 0.70
downloadBinaryFunction · 0.70

Calls 4

buildRequestOptionsFunction · 0.70
getMethod · 0.65
onMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected