@mepkg/maxios 1.2.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/maxios.js +2 -1
- package/src/tls-client.js +19 -7
package/package.json
CHANGED
package/src/maxios.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {HttpProxyAgent, HttpsProxyAgent} from "hpagent";
|
|
2
2
|
import {cookiesFromResponse, cookiesToHeader} from "melperjs";
|
|
3
|
-
import
|
|
3
|
+
import isNil from "es-toolkit/compat/isNil";
|
|
4
|
+
import omitBy from "es-toolkit/compat/omitBy";
|
|
4
5
|
import axios from "axios";
|
|
5
6
|
|
|
6
7
|
|
package/src/tls-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {cookiesFromResponse, cookiesToHeader, Exception} from "melperjs";
|
|
2
|
-
import
|
|
2
|
+
import isNil from "es-toolkit/compat/isNil";
|
|
3
|
+
import omitBy from "es-toolkit/compat/omitBy";
|
|
3
4
|
import {maxios} from "./maxios.js";
|
|
4
5
|
|
|
5
6
|
|
|
@@ -16,11 +17,21 @@ export class TlsClient {
|
|
|
16
17
|
impersonate = "chrome_windows",
|
|
17
18
|
visit = null,
|
|
18
19
|
maxRedirects = 0,
|
|
19
|
-
|
|
20
|
+
requestBodyFormat = "text",
|
|
21
|
+
responseBodyFormat = "text",
|
|
20
22
|
validateStatus = (status) => (status >= 200 && status <= 299) || (maxRedirects && status >= 300 && status <= 399)
|
|
21
23
|
} = {}, cookies = {}) {
|
|
22
24
|
this.proxy = proxy;
|
|
23
|
-
this.config = {
|
|
25
|
+
this.config = {
|
|
26
|
+
timeout,
|
|
27
|
+
httpVersion,
|
|
28
|
+
impersonate,
|
|
29
|
+
visit,
|
|
30
|
+
maxRedirects,
|
|
31
|
+
requestBodyFormat,
|
|
32
|
+
responseBodyFormat,
|
|
33
|
+
validateStatus
|
|
34
|
+
};
|
|
24
35
|
this.cookies = cookies;
|
|
25
36
|
this.tlsServer = tlsServer;
|
|
26
37
|
if (!this.tlsServer.url) {
|
|
@@ -40,7 +51,8 @@ export class TlsClient {
|
|
|
40
51
|
impersonate,
|
|
41
52
|
visit,
|
|
42
53
|
maxRedirects,
|
|
43
|
-
|
|
54
|
+
requestBodyFormat,
|
|
55
|
+
responseBodyFormat,
|
|
44
56
|
validateStatus
|
|
45
57
|
} = {}) {
|
|
46
58
|
let tlsResponse;
|
|
@@ -67,7 +79,6 @@ export class TlsClient {
|
|
|
67
79
|
}
|
|
68
80
|
url = parsedUrl.toString();
|
|
69
81
|
}
|
|
70
|
-
maxRedirects = maxRedirects ?? this.config.maxRedirects;
|
|
71
82
|
const request = {
|
|
72
83
|
"method": method || "GET",
|
|
73
84
|
"url": url,
|
|
@@ -78,8 +89,9 @@ export class TlsClient {
|
|
|
78
89
|
"proxy": proxy || this.proxy || undefined,
|
|
79
90
|
"impersonate": impersonate || this.config.impersonate,
|
|
80
91
|
"visit": visit || this.config.visit,
|
|
81
|
-
"maxRedirects": maxRedirects,
|
|
82
|
-
"
|
|
92
|
+
"maxRedirects": maxRedirects ?? this.config.maxRedirects,
|
|
93
|
+
"requestBodyFormat": requestBodyFormat || this.config.requestBodyFormat,
|
|
94
|
+
"responseBodyFormat": responseBodyFormat || this.config.responseBodyFormat,
|
|
83
95
|
"key": this.tlsServer.key
|
|
84
96
|
};
|
|
85
97
|
this.#requestCookies(request);
|