mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-07 17:12:06 +08:00
request.js替换废弃方法
This commit is contained in:
@ -1,11 +1,10 @@
|
|||||||
const encrypt = require('./crypto')
|
const encrypt = require('./crypto')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const queryString = require('querystring')
|
|
||||||
const PacProxyAgent = require('pac-proxy-agent')
|
const PacProxyAgent = require('pac-proxy-agent')
|
||||||
const http = require('http')
|
const http = require('http')
|
||||||
const https = require('https')
|
const https = require('https')
|
||||||
const tunnel = require('tunnel')
|
const tunnel = require('tunnel')
|
||||||
const qs = require('url')
|
const { URLSearchParams, URL } = require('url')
|
||||||
// request.debug = true // 开启可看到更详细信息
|
// request.debug = true // 开启可看到更详细信息
|
||||||
|
|
||||||
const chooseUserAgent = (ua = false) => {
|
const chooseUserAgent = (ua = false) => {
|
||||||
@ -115,7 +114,7 @@ const createRequest = (method, url, data, options) => {
|
|||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
data: queryString.stringify(data),
|
data: new URLSearchParams(data).toString(),
|
||||||
httpAgent: new http.Agent({ keepAlive: true }),
|
httpAgent: new http.Agent({ keepAlive: true }),
|
||||||
httpsAgent: new https.Agent({ keepAlive: true }),
|
httpsAgent: new https.Agent({ keepAlive: true }),
|
||||||
}
|
}
|
||||||
@ -127,7 +126,7 @@ const createRequest = (method, url, data, options) => {
|
|||||||
settings.httpAgent = new PacProxyAgent(options.proxy)
|
settings.httpAgent = new PacProxyAgent(options.proxy)
|
||||||
settings.httpsAgent = new PacProxyAgent(options.proxy)
|
settings.httpsAgent = new PacProxyAgent(options.proxy)
|
||||||
} else {
|
} else {
|
||||||
const purl = qs.parse(options.proxy)
|
const purl = new URL(options.proxy)
|
||||||
if (purl.hostname) {
|
if (purl.hostname) {
|
||||||
const agent = tunnel.httpsOverHttp({
|
const agent = tunnel.httpsOverHttp({
|
||||||
proxy: {
|
proxy: {
|
||||||
|
Reference in New Issue
Block a user