/lib/HTTPConversation.class.js (5c32b1695313c9421915911e11e0993503911b37) (3899 bytes) (mode 100644) (type blob)
/*
This file is part of datajams-evictions.
datajams-evictions is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
datajams-evictions is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with datajams-evictions. If not, see <https://www.gnu.org/licenses/>.
Copyright 2020 Luigi Bai
*/
const https = require("https");
const httpOpts = require("./httpOptions");
const tough = require("tough-cookie");
module.exports = class {
constructor(argv) {
let opts = argv || {};
this.debug = opts.debug;
this.verbose = opts.verbose;
this.jar = (new tough.CookieJar());
};
postURLData(argv) {
let args = argv || {};
if (! args.reqPath) throw "Must have a request path.";
if (! args.reqHost) throw "Must have a request host.";
let opts = new httpOpts();
opts.host = args.reqHost;
opts.path = args.reqPath;
opts.method = "POST";
opts.headers["content-type"] = "application/x-www-form-urlencoded";
delete opts.headers["Accept-Encoding"];
this.referURL && (opts.headers["referer"] = this.referURL);
let reqURL = opts.protocol+"//"+opts.host+opts.path;
opts.headers["cookie"] = this.jar.getSetCookieStringsSync(reqURL);
this.debug && console.log(opts);
this.debug && console.log(reqURL);
// With the data all set up, now connect and parse:
let req = https.request(opts, (res) => {
this.debug && console.log(res);
res.headers["set-cookie"] && res.headers["set-cookie"].map((cookie) => { this.jar.setCookieSync(cookie, reqURL); });
// What to do with incoming data:
let doc = "";
res.on("data", (d) => {
this.verbose && console.log("postURLData", d.toString());
if (args.parser) {
args.parser.parseChunk(d);
} else {
doc = doc + d;
}
}).on("end", () => {
this.referURL = reqURL;
args.parser && args.parser.done();
args.callback && "function" === typeof args.callback && args.callback(doc);
});
});
req.on('error', (e) => {
console.error(reqURL, e);
});
let us = new URLSearchParams(args.data);
this.debug && console.log("data: ", us.toString());
req.write(us.toString());
// Ok GO:
req.end();
};
getURL(argv) {
let args = argv || {};
if (! args.reqPath) throw "Must have a request path.";
if (! args.reqHost) throw "Must have a request host.";
let opts = new httpOpts();
opts.protocol = "https:";
opts.host = args.reqHost;
opts.path = args.reqPath;
opts.method = "GET";
this.referURL && (opts.headers["referer"] = this.referURL);
let reqURL = opts.protocol+"//"+opts.host+opts.path;
opts.headers["cookie"] = this.jar.getSetCookieStringsSync(reqURL);
this.debug && console.log(opts);
this.debug && console.log(reqURL);
// With the data all set up, now connect and parse:
let req = https.request(opts, (res) => {
this.debug && console.log(res);
res.headers["set-cookie"] && res.headers["set-cookie"].map((cookie) => { this.jar.setCookieSync(cookie, reqURL); });
// What to do with incoming data:
let doc = "";
res.on("data", (d) => {
this.verbose && console.log("getURL", d.toString());
if (args.parser) {
args.parser.parseChunk(d);
} else {
doc = doc + d;
}
}).on("end", () => {
this.referURL = reqURL;
args.parser && args.parser.done();
args.callback && "function" === typeof args.callback && args.callback(doc);
});
});
req.on('error', (e) => {
console.error(reqURL, e);
});
// Ok GO:
req.end();
};
};
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
31 |
ce60eb947708d4530bee8739c111f9c0ab750eaa |
.gitignore |
100644 |
blob |
33877 |
e37e32e4e836c2394b62c0a848c2094f687eb530 |
LICENSE |
100644 |
blob |
1171 |
354a297411cdddbe0355507766510a182aba0874 |
Promise.shim.js |
100644 |
blob |
384 |
4f72a1e5d3c830cb6a5f962a320da2d22567f82d |
README.md |
100644 |
blob |
364 |
c97984072c2cd4c8daa74c3e6ff6eb0434dc5d72 |
creds.example.js |
040000 |
tree |
- |
2f905348757f0e27d93465c3a1a1100dce0f80bf |
lib |
100644 |
blob |
3385 |
a0eb075e7aa659c0f83bbfc988ced15555227e9e |
loadDockets.js |
100644 |
blob |
49738 |
d6ac529ef6f7718e7bb1770f5544f35238738473 |
package-lock.json |
100644 |
blob |
627 |
1dbf524b42fda0760f06490e6c8dd142cab2308c |
package.json |
100644 |
blob |
2130 |
69eac4aecd2ae8d90fb05de3e27156fd8a0d590d |
schema.mssql.sql |
100644 |
blob |
1032 |
dd314aae1344ab599bf5ad4a79b64e3f129a6abb |
schema.sqlite3.sql |
100644 |
blob |
1608 |
1086eccf9183298d0fdedf88b8bc19c9a6159278 |
searchNames.js |
100755 |
blob |
162 |
7c25a482064c9580388f09c4d91683f3858ff7ca |
sqdump |
100644 |
blob |
2181 |
66cb76343f7b83906ea940e9a5ccf90ce7f024e1 |
updateStatus.js |
100644 |
blob |
6576 |
67a852a1d29d13ecbea36711fea8ba8b3bd18fcf |
xferData.js |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/datajams-lbai/datajams-evictions
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/datajams-lbai/datajams-evictions
Clone this repository using git:
git clone git://git.rocketgit.com/user/datajams-lbai/datajams-evictions
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main