@mepkg/maxios 1.2.0 → 2.0.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tls-client.js +17 -6
package/package.json CHANGED
@@ -19,5 +19,5 @@
19
19
  "lodash-es": "^4.18.1",
20
20
  "melperjs": "^17.0.0"
21
21
  },
22
- "version": "1.2.0"
22
+ "version": "2.0.0"
23
23
  }
package/src/tls-client.js CHANGED
@@ -16,11 +16,21 @@ export class TlsClient {
16
16
  impersonate = "chrome_windows",
17
17
  visit = null,
18
18
  maxRedirects = 0,
19
- base64 = false,
19
+ requestBodyFormat = "text",
20
+ responseBodyFormat = "text",
20
21
  validateStatus = (status) => (status >= 200 && status <= 299) || (maxRedirects && status >= 300 && status <= 399)
21
22
  } = {}, cookies = {}) {
22
23
  this.proxy = proxy;
23
- this.config = {timeout, httpVersion, impersonate, visit, maxRedirects, base64, validateStatus};
24
+ this.config = {
25
+ timeout,
26
+ httpVersion,
27
+ impersonate,
28
+ visit,
29
+ maxRedirects,
30
+ requestBodyFormat,
31
+ responseBodyFormat,
32
+ validateStatus
33
+ };
24
34
  this.cookies = cookies;
25
35
  this.tlsServer = tlsServer;
26
36
  if (!this.tlsServer.url) {
@@ -40,7 +50,8 @@ export class TlsClient {
40
50
  impersonate,
41
51
  visit,
42
52
  maxRedirects,
43
- base64,
53
+ requestBodyFormat,
54
+ responseBodyFormat,
44
55
  validateStatus
45
56
  } = {}) {
46
57
  let tlsResponse;
@@ -67,7 +78,6 @@ export class TlsClient {
67
78
  }
68
79
  url = parsedUrl.toString();
69
80
  }
70
- maxRedirects = maxRedirects ?? this.config.maxRedirects;
71
81
  const request = {
72
82
  "method": method || "GET",
73
83
  "url": url,
@@ -78,8 +88,9 @@ export class TlsClient {
78
88
  "proxy": proxy || this.proxy || undefined,
79
89
  "impersonate": impersonate || this.config.impersonate,
80
90
  "visit": visit || this.config.visit,
81
- "maxRedirects": maxRedirects,
82
- "base64": base64 ?? this.config.base64,
91
+ "maxRedirects": maxRedirects ?? this.config.maxRedirects,
92
+ "requestBodyFormat": requestBodyFormat || this.config.requestBodyFormat,
93
+ "responseBodyFormat": responseBodyFormat || this.config.responseBodyFormat,
83
94
  "key": this.tlsServer.key
84
95
  };
85
96
  this.#requestCookies(request);