NPM版本-3.5.2
节点版本-v8.10.0
Request-Promise-“ request-promise”:“ ^ 4.2.2”
使用代理时,在运行NodeJS和NPM的Ubuntu 18.04服务器上出现问题。我收到错误Request path contains unescaped characters
当我不使用代理时,请求正常运行。绝对不是编码问题。
我尝试了不同的URL
async makeRequest(opts = {}) {
let id = Math.random().toString(36).substring(7);
var msg = `[${id}] Request to ${opts.url}`
msg += (opts.proxy !== undefined) ? ` | ${opts.proxy}` : ``;
this.ts(msg)
var resp = this.request(opts).then((res) => {
var msg = `[${id}] Status: ${res.statusCode}`;
msg += (res.headers.location !== undefined) ? ` | Location: ${res.headers.location}` : ``;
this.ts(msg);
res.id = id;
return res;
}).catch((err) => {
// console.log(err);
this.ts(`[${id}] ${err.name} - ${err.message}`)
return false;
})
return resp
}
选项看起来像
{
url: "https://google.com",
proxy: "http://user:pass@proxyserver:port"
}