MCPcopy Create free account
hub / github.com/Semporia/Scripts / get

Method get

jd_try.js:785–869  ·  view source on GitHub ↗
(opts, callback = () => {})

Source from the content-addressed store, hash-verified

783 }
784
785 get(opts, callback = () => {}) {
786 if (opts.headers) {
787 delete opts.headers['Content-Type']
788 delete opts.headers['Content-Length']
789 }
790 if (this.isSurge() || this.isLoon()) {
791 if (this.isSurge() && this.isNeedRewrite) {
792 opts.headers = opts.headers || {}
793 Object.assign(opts.headers, {
794 'X-Surge-Skip-Scripting': false
795 })
796 }
797 $httpClient.get(opts, (err, resp, body) => {
798 if (!err && resp) {
799 resp.body = body
800 resp.statusCode = resp.status
801 }
802 callback(err, resp, body)
803 })
804 } else if (this.isQuanX()) {
805 if (this.isNeedRewrite) {
806 opts.opts = opts.opts || {}
807 Object.assign(opts.opts, {
808 hints: false
809 })
810 }
811 $task.fetch(opts).then(
812 (resp) => {
813 const {
814 statusCode: status,
815 statusCode,
816 headers,
817 body
818 } = resp
819 callback(null, {
820 status,
821 statusCode,
822 headers,
823 body
824 }, body)
825 },
826 (err) => callback(err)
827 )
828 } else if (this.isNode()) {
829 this.initGotEnv(opts)
830 this.got(opts)
831 .on('redirect', (resp, nextOpts) => {
832 try {
833 if (resp.headers['set-cookie']) {
834 const ck = resp.headers['set-cookie'].map(this.cktough.Cookie.parse).toString()
835 if (ck) {
836 this.ckjar.setCookieSync(ck, null)
837 }
838 nextOpts.cookieJar = this.ckjar
839 }
840 } catch (e) {
841 this.logErr(e)
842 }

Callers 8

getGoodListByCondFunction · 0.45
optFunction · 0.45
canTryFunction · 0.45
isFollowedFunction · 0.45
followShopFunction · 0.45
doTryFunction · 0.45
getSuccessListFunction · 0.45
getScriptMethod · 0.45

Calls 7

callbackFunction · 0.85
isSurgeMethod · 0.45
isLoonMethod · 0.45
isQuanXMethod · 0.45
isNodeMethod · 0.45
initGotEnvMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected