Update http.js

This commit is contained in:
Namhyeon Go 2022-01-17 18:58:52 +09:00 committed by GitHub
parent 3f786a3faf
commit e7ebb7fac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,13 @@ var HTTPObject = function(engine) {
this.dataType = null;
this.userAgent = "WelsonJS/0.1.4-dev (https://github.com/gnh1201/welsonjs)";
this.isAsync = false;
this.proxy = {
"enabled": false,
"protocol": "http",
"host": "127.0.0.1",
"port": 80,
"credential": null // { username: "user", password: "pass" }
};
this.engine = (typeof(engine) !== "undefined" ? engine : "MSXML");
this.cookie = null;
@ -366,6 +373,32 @@ var HTTPObject = function(engine) {
cmd.push("-d");
cmd.push(this.requestBody);
}
// Add proxy: <[protocol://][user:password@]proxyhost[:port]>
if (this.proxy != null && this.proxy.enabled) {
cmd.push("-x");
if (this.proxy.credential != null) {
cmd.push([
this.proxy.protocol,
"://",
this.proxy.credential.username,
":",
this.proxy.credential.password,
"@",
this.proxy.host,
":",
this.proxy.port
].join(""));
} else {
cmd.push([
this.proxy.protocol,
"://",
this.proxy.host,
":",
this.proxy.port
].join(""));
}
}
cmd.push(state.url);