mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
fix and test ok #143
This commit is contained in:
parent
3842d1bea8
commit
abe59228be
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"description": "WelsonJS test profile (test-misc.json)",
|
||||
"released": "2024-08-29",
|
||||
"released": "2024-09-25",
|
||||
"dependencies": {
|
||||
"welsonjs": "0.2.7"
|
||||
},
|
||||
|
@ -90,6 +90,11 @@
|
|||
"id": "domparser_test",
|
||||
"description": "DOMParser compatibility test",
|
||||
"tags": ["Standards"]
|
||||
},
|
||||
{
|
||||
"id": "proxy_custom_provider",
|
||||
"description": "HTTP proxy with a custom provider",
|
||||
"tags": ["Network", "HTTP"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
17
lib/http.js
17
lib/http.js
|
@ -258,12 +258,13 @@ var HTTPObject = function(engine) {
|
|||
this.proxy.provider = proxy['provider'];
|
||||
|
||||
if (proxyType == "stateless") {
|
||||
this.proxy.url = this.evaluate(availableProxy.url);
|
||||
this.proxy.url = availableProxy.url;
|
||||
} else {
|
||||
this.proxy.protocol = proxy['protocol'] || this.proxy.protocol;
|
||||
this.proxy.host = proxy['host'] || this.proxy.host;
|
||||
this.proxy.port = proxy['port'] || this.proxy.port;
|
||||
this.proxy.credential = proxy['credential'] || this.proxy.credential;
|
||||
this.proxy.url = proxy['url'] || this.proxy.url;
|
||||
}
|
||||
|
||||
console.info("Please check documentation:", availableProxy.documentation);
|
||||
|
@ -277,6 +278,9 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.proxy[k] = proxy[k];
|
||||
}
|
||||
|
||||
// check proxy configuration
|
||||
console.info("Proxy Configuration:", JSON.stringify(this.proxy));
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -473,10 +477,10 @@ var HTTPObject = function(engine) {
|
|||
};
|
||||
|
||||
this.getProxiedURL = function(url) {
|
||||
if (this.proxy != null && this.proxy.enabled && this.proxy.type == "stateless") {
|
||||
this.setVariable("url", encodeURIComponent(url));
|
||||
url = this.evaluate(this.proxy.url);
|
||||
}
|
||||
this.setVariable("url", encodeURIComponent(url));
|
||||
url = this.evaluate(this.proxy.url);
|
||||
|
||||
console.log("Requested URL (Proxied):", url);
|
||||
|
||||
return url;
|
||||
};
|
||||
|
@ -865,6 +869,7 @@ var HTTPObject = function(engine) {
|
|||
|
||||
this.setVariable = function(k, v) {
|
||||
this.variables[k] = v;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setVariables = function(variables) {
|
||||
|
@ -1167,7 +1172,7 @@ exports.parseURL = parseURL;
|
|||
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
||||
exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible
|
||||
|
||||
exports.VERSIONINFO = "HTTP REST Client (http.js) version 0.7.32";
|
||||
exports.VERSIONINFO = "HTTP REST Client (http.js) version 0.7.34";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
|
@ -977,10 +977,10 @@ var test_implements = {
|
|||
},
|
||||
|
||||
// https://stackoverflow.com/questions/33417367/example-of-how-to-use-peg-js
|
||||
"pegjs": {
|
||||
"pegjs": function() {
|
||||
var syntax = FILE.readFile("app/assets/pegjs/test.pegjs", FILE.CdoCharset.CdoUTF_8);
|
||||
var parser = PEG.generate(syntax);
|
||||
console.log(JSON.stringify(parser.parse("test123"));
|
||||
console.log(JSON.stringify(parser.parse("test123")));
|
||||
},
|
||||
|
||||
"domparser_test": function() {
|
||||
|
@ -1002,10 +1002,27 @@ var test_implements = {
|
|||
console.log(JSON.stringify(result));
|
||||
}
|
||||
},
|
||||
|
||||
// [lib/http] Proxy API services integration #143
|
||||
|
||||
// [lib/http] Proxy API services integration #143
|
||||
"proxy_custom_provider": function() {
|
||||
// todo
|
||||
var HTTP = require("lib/http");
|
||||
|
||||
var response = HTTP.create("CURL")
|
||||
.setVariables({
|
||||
"api_key": "YOUR_API_KEY",
|
||||
"render_js": "false",
|
||||
"residential": "false",
|
||||
"country": "us"
|
||||
})
|
||||
.setProxy({
|
||||
"enabled": true,
|
||||
"provider": "scrapeops",
|
||||
"type": "stateless"
|
||||
})
|
||||
.open("GET", "https://example.org")
|
||||
.send();
|
||||
|
||||
console.log("responseBody:", response.responseBody);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user