MCPcopy Create free account
hub / github.com/TGX-Android/Publisher / fetchHttp

Function fetchHttp

main.js:420–438  ·  view source on GitHub ↗
(url, needBinary, httpOptions)

Source from the content-addressed store, hash-verified

418}
419
420function fetchHttp (url, needBinary, httpOptions) {
421 return new Promise((accept, reject) => {
422 const parsed = new URL(url);
423 const protocol = (parsed.protocol === 'https:' ? https : http);
424 try {
425 protocol.get(Object.assign({
426 host: parsed.host,
427 path: parsed.pathname + parsed.search
428 }, httpOptions || {}), (res) => {
429 toUtf8(res, (contentType, content) => {
430 accept({statusCode: res.statusCode, statusMessage: res.statusMessage, content, contentType});
431 }, needBinary);
432 }).on('error', reject);
433 } catch (e) {
434 console.error('Cannot fetch', url, e);
435 reject(e);
436 }
437 });
438}
439
440function uploadHttpFile (url, filePath, httpHeaders, httpOptions, needBinary) {
441 return new Promise((accept, reject) => {

Callers 4

obtainHuaweiUploadUrlFunction · 0.85
deleteGitHubReleaseFunction · 0.85

Calls 1

toUtf8Function · 0.85

Tested by

no test coverage detected