@e-mc/request 0.11.3 → 0.11.4

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 (3) hide show
  1. package/README.md +4 -4
  2. package/index.js +7 -2
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.11.3/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.11.4/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IModule, ModuleConstructor } from "./index";
@@ -209,9 +209,9 @@ instance.get("http://hostname/path/config.yml", options).then(data => {
209
209
 
210
210
  ## References
211
211
 
212
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/http.d.ts
213
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/request.d.ts
214
- - https://www.unpkg.com/@e-mc/types@0.11.3/lib/settings.d.ts
212
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/http.d.ts
213
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/request.d.ts
214
+ - https://www.unpkg.com/@e-mc/types@0.11.4/lib/settings.d.ts
215
215
 
216
216
  * https://www.npmjs.com/package/@types/node
217
217
 
package/index.js CHANGED
@@ -37,6 +37,7 @@ const kStatusOn = Symbol('statusOn');
37
37
  const kHeadersOn = Symbol('headersOn');
38
38
  const kAdapter = Symbol('adapter');
39
39
  const SUPPORTED_NODE20 = (0, types_1.supported)(20);
40
+ const SUPPORTED_ZSTD = (0, types_1.supported)(23, 8) && typeof zlib.createZstdDecompress === 'function';
40
41
  const REGEXP_PEMCERT = /^-{3,}[ \t]*BEGIN[ \t].+\n-{3,}[ \t]*END[ \t][^-]+-{3,}$/s;
41
42
  const REGEXP_GLOBWITHIN = /\\\?|(?:(?<!\\)(?:\*|\[!?[^!\]]+\]|\{(?:[^,]+,)+[^}]+\}|[!?+*@]\((?:[^|]+\|)*[^)]+\)|\?.*\?|\?$))/;
42
43
  const HTTP = {
@@ -328,6 +329,9 @@ function decompressEncoding(value, chunkSize) {
328
329
  if (LIB_ZSTD) {
329
330
  return new LIB_ZSTD.ZstdDecompressTransform({ writableHighWaterMark: chunkSize });
330
331
  }
332
+ if (SUPPORTED_ZSTD) {
333
+ return zlib.createZstdDecompress({ chunkSize });
334
+ }
331
335
  break;
332
336
  }
333
337
  }
@@ -1433,7 +1437,7 @@ class Request extends module_1 {
1433
1437
  const baseHeaders = this.headersOf(uri);
1434
1438
  let request, ca, cert, key, ciphers, minVersion;
1435
1439
  if (getting && this.acceptEncoding && !host.localhost && !baseHeaders?.['accept-encoding']) {
1436
- (headers ||= {})['accept-encoding'] ||= 'gzip, deflate, br' + (LIB_ZSTD ? ', zstd' : '');
1440
+ (headers ||= {})['accept-encoding'] ||= 'gzip, deflate, br' + (LIB_ZSTD || SUPPORTED_ZSTD ? ', zstd' : '');
1437
1441
  }
1438
1442
  if (posting && options.postData) {
1439
1443
  if (expectContinue) {
@@ -1767,7 +1771,7 @@ class Request extends module_1 {
1767
1771
  else {
1768
1772
  options = {};
1769
1773
  }
1770
- const headers = (0, util_1.parseOutgoingHeaders)(options.headers ||= {});
1774
+ const headers = (0, util_1.parseOutgoingHeaders)(options.headers) || {};
1771
1775
  for (const attr in headers) {
1772
1776
  const name = attr.toLowerCase();
1773
1777
  if (name === 'content-type' || name === 'content-length') {
@@ -1877,6 +1881,7 @@ class Request extends module_1 {
1877
1881
  options.httpVersion = 1;
1878
1882
  options.postData = data;
1879
1883
  headers['content-type'] = contentType || "text/plain";
1884
+ options.headers = headers;
1880
1885
  return this.get(uri, options);
1881
1886
  }
1882
1887
  async get(uri, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "Request constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.11.3",
24
- "@e-mc/types": "0.11.3",
23
+ "@e-mc/module": "0.11.4",
24
+ "@e-mc/types": "0.11.4",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^4.0.2",