| 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 |