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

Method get

jd_goodMorning.js:319–368  ·  view source on GitHub ↗
(t, e = (() => {}))

Source from the content-addressed store, hash-verified

317 this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar))
318 }
319 get(t, e = (() => {})) {
320 t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {
321 "X-Surge-Skip-Scripting": !1
322 })), $httpClient.get(t, (t, s, i) => {
323 !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
324 })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
325 hints: !1
326 })), $task.fetch(t).then(t => {
327 const {
328 statusCode: s,
329 statusCode: i,
330 headers: r,
331 body: o
332 } = t;
333 e(null, {
334 status: s,
335 statusCode: i,
336 headers: r,
337 body: o
338 }, o)
339 }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => {
340 try {
341 if (t.headers["set-cookie"]) {
342 const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
343 s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar
344 }
345 } catch (t) {
346 this.logErr(t)
347 }
348 }).then(t => {
349 const {
350 statusCode: s,
351 statusCode: i,
352 headers: r,
353 body: o
354 } = t;
355 e(null, {
356 status: s,
357 statusCode: i,
358 headers: r,
359 body: o
360 }, o)
361 }, t => {
362 const {
363 message: s,
364 response: i
365 } = t;
366 e(s, i, i && i.body)
367 }))
368 }
369 post(t, e = (() => {})) {
370 if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {
371 "X-Surge-Skip-Scripting": !1

Callers 2

goodMorningFunction · 0.45
getScriptMethod · 0.45

Calls 7

eFunction · 0.70
isSurgeMethod · 0.45
isLoonMethod · 0.45
isQuanXMethod · 0.45
isNodeMethod · 0.45
initGotEnvMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected