(t, e = () => {})
| 299 | } |
| 300 | } |
| 301 | post(t, e = () => {}) { |
| 302 | const s = t.method ? t.method.toLocaleLowerCase() : 'post' |
| 303 | switch ( |
| 304 | (t.body && |
| 305 | t.headers && |
| 306 | !t.headers['Content-Type'] && |
| 307 | !t.headers['content-type'] && |
| 308 | (t.headers['content-type'] = 'application/x-www-form-urlencoded'), |
| 309 | t.headers && (delete t.headers['Content-Length'], delete t.headers['content-length']), |
| 310 | this.getEnv()) |
| 311 | ) { |
| 312 | case 'Surge': |
| 313 | case 'Loon': |
| 314 | case 'Stash': |
| 315 | case 'Shadowrocket': |
| 316 | default: |
| 317 | this.isSurge() && |
| 318 | this.isNeedRewrite && |
| 319 | ((t.headers = t.headers || {}), Object.assign(t.headers, { 'X-Surge-Skip-Scripting': !1 })), |
| 320 | $httpClient[s](t, (t, s, a) => { |
| 321 | !t && s && ((s.body = a), (s.statusCode = s.status ? s.status : s.statusCode), (s.status = s.statusCode)), |
| 322 | e(t, s, a) |
| 323 | }) |
| 324 | break |
| 325 | case 'Quantumult X': |
| 326 | ;(t.method = s), |
| 327 | this.isNeedRewrite && ((t.opts = t.opts || {}), Object.assign(t.opts, { hints: !1 })), |
| 328 | $task.fetch(t).then( |
| 329 | t => { |
| 330 | const { statusCode: s, statusCode: a, headers: r, body: i, bodyBytes: o } = t |
| 331 | e(null, { status: s, statusCode: a, headers: r, body: i, bodyBytes: o }, i, o) |
| 332 | }, |
| 333 | t => e((t && t.error) || 'UndefinedError') |
| 334 | ) |
| 335 | break |
| 336 | case 'Node.js': |
| 337 | let a = require('iconv-lite') |
| 338 | this.initGotEnv(t) |
| 339 | const { url: r, ...i } = t |
| 340 | this.got[s](r, i).then( |
| 341 | t => { |
| 342 | const { statusCode: s, statusCode: r, headers: i, rawBody: o } = t, |
| 343 | n = a.decode(o, this.encoding) |
| 344 | e(null, { status: s, statusCode: r, headers: i, rawBody: o, body: n }, n) |
| 345 | }, |
| 346 | t => { |
| 347 | const { message: s, response: r } = t |
| 348 | e(s, r, r && a.decode(r.rawBody, this.encoding)) |
| 349 | } |
| 350 | ) |
| 351 | } |
| 352 | } |
| 353 | time(t, e = null) { |
| 354 | const s = e ? new Date(e) : new Date() |
| 355 | let a = { |
no test coverage detected