nlcurl 0.7.0 → 0.9.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.
- package/README.md +149 -140
- package/dist/cache/groups.d.ts +75 -0
- package/dist/cache/groups.d.ts.map +1 -0
- package/dist/cache/groups.js +118 -0
- package/dist/cache/groups.js.map +1 -0
- package/dist/cache/no-vary-search.d.ts +33 -0
- package/dist/cache/no-vary-search.d.ts.map +1 -0
- package/dist/cache/no-vary-search.js +148 -0
- package/dist/cache/no-vary-search.js.map +1 -0
- package/dist/cache/range.d.ts +120 -0
- package/dist/cache/range.d.ts.map +1 -0
- package/dist/cache/range.js +193 -0
- package/dist/cache/range.js.map +1 -0
- package/dist/cache/store.d.ts +75 -37
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +217 -85
- package/dist/cache/store.js.map +1 -1
- package/dist/cache/types.d.ts +10 -39
- package/dist/cache/types.d.ts.map +1 -1
- package/dist/cli/args.d.ts +4 -37
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +3 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/index.d.ts +0 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/output.d.ts +14 -20
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +14 -20
- package/dist/cli/output.js.map +1 -1
- package/dist/cookies/jar.d.ts +41 -40
- package/dist/cookies/jar.d.ts.map +1 -1
- package/dist/cookies/jar.js +65 -42
- package/dist/cookies/jar.js.map +1 -1
- package/dist/cookies/parser.d.ts +13 -17
- package/dist/cookies/parser.d.ts.map +1 -1
- package/dist/cookies/parser.js +23 -15
- package/dist/cookies/parser.js.map +1 -1
- package/dist/cookies/psl-data.d.ts +1 -1
- package/dist/cookies/psl-data.js +1 -1
- package/dist/cookies/public-suffix.d.ts +5 -27
- package/dist/cookies/public-suffix.d.ts.map +1 -1
- package/dist/cookies/public-suffix.js +5 -37
- package/dist/cookies/public-suffix.js.map +1 -1
- package/dist/core/auth.d.ts +61 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +159 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/client.d.ts +28 -40
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +31 -41
- package/dist/core/client.js.map +1 -1
- package/dist/core/errors.d.ts +64 -88
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +64 -88
- package/dist/core/errors.js.map +1 -1
- package/dist/core/request.d.ts +33 -113
- package/dist/core/request.d.ts.map +1 -1
- package/dist/core/response.d.ts +49 -66
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +45 -59
- package/dist/core/response.js.map +1 -1
- package/dist/core/session.d.ts +66 -78
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +136 -77
- package/dist/core/session.js.map +1 -1
- package/dist/core/validation.d.ts +58 -43
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +141 -56
- package/dist/core/validation.js.map +1 -1
- package/dist/dns/cache.d.ts +65 -0
- package/dist/dns/cache.d.ts.map +1 -0
- package/dist/dns/cache.js +119 -0
- package/dist/dns/cache.js.map +1 -0
- package/dist/dns/codec.d.ts +29 -19
- package/dist/dns/codec.d.ts.map +1 -1
- package/dist/dns/codec.js +73 -39
- package/dist/dns/codec.js.map +1 -1
- package/dist/dns/doh-resolver.d.ts +17 -31
- package/dist/dns/doh-resolver.d.ts.map +1 -1
- package/dist/dns/doh-resolver.js +47 -48
- package/dist/dns/doh-resolver.js.map +1 -1
- package/dist/dns/dot-resolver.d.ts +89 -0
- package/dist/dns/dot-resolver.d.ts.map +1 -0
- package/dist/dns/dot-resolver.js +166 -0
- package/dist/dns/dot-resolver.js.map +1 -0
- package/dist/dns/https-rr.d.ts +19 -30
- package/dist/dns/https-rr.d.ts.map +1 -1
- package/dist/dns/https-rr.js +22 -40
- package/dist/dns/https-rr.js.map +1 -1
- package/dist/dns/types.d.ts +31 -59
- package/dist/dns/types.d.ts.map +1 -1
- package/dist/dns/types.js +3 -14
- package/dist/dns/types.js.map +1 -1
- package/dist/fingerprints/akamai.d.ts +3 -11
- package/dist/fingerprints/akamai.d.ts.map +1 -1
- package/dist/fingerprints/akamai.js +3 -11
- package/dist/fingerprints/akamai.js.map +1 -1
- package/dist/fingerprints/database.d.ts +6 -14
- package/dist/fingerprints/database.d.ts.map +1 -1
- package/dist/fingerprints/database.js +6 -14
- package/dist/fingerprints/database.js.map +1 -1
- package/dist/fingerprints/extensions.d.ts +56 -71
- package/dist/fingerprints/extensions.d.ts.map +1 -1
- package/dist/fingerprints/extensions.js +58 -71
- package/dist/fingerprints/extensions.js.map +1 -1
- package/dist/fingerprints/ja3.d.ts +12 -30
- package/dist/fingerprints/ja3.d.ts.map +1 -1
- package/dist/fingerprints/ja3.js +12 -30
- package/dist/fingerprints/ja3.js.map +1 -1
- package/dist/fingerprints/ja4.d.ts +18 -0
- package/dist/fingerprints/ja4.d.ts.map +1 -0
- package/dist/fingerprints/ja4.js +81 -0
- package/dist/fingerprints/ja4.js.map +1 -0
- package/dist/fingerprints/profiles/chrome.d.ts +18 -21
- package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
- package/dist/fingerprints/profiles/chrome.js +35 -31
- package/dist/fingerprints/profiles/chrome.js.map +1 -1
- package/dist/fingerprints/profiles/edge.d.ts +7 -10
- package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
- package/dist/fingerprints/profiles/edge.js +7 -10
- package/dist/fingerprints/profiles/edge.js.map +1 -1
- package/dist/fingerprints/profiles/firefox.d.ts +8 -11
- package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
- package/dist/fingerprints/profiles/firefox.js +8 -11
- package/dist/fingerprints/profiles/firefox.js.map +1 -1
- package/dist/fingerprints/profiles/safari.d.ts +11 -14
- package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
- package/dist/fingerprints/profiles/safari.js +11 -14
- package/dist/fingerprints/profiles/safari.js.map +1 -1
- package/dist/fingerprints/profiles/tor.d.ts +5 -8
- package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
- package/dist/fingerprints/profiles/tor.js +5 -8
- package/dist/fingerprints/profiles/tor.js.map +1 -1
- package/dist/fingerprints/types.d.ts +42 -73
- package/dist/fingerprints/types.d.ts.map +1 -1
- package/dist/hsts/store.d.ts +19 -21
- package/dist/hsts/store.d.ts.map +1 -1
- package/dist/hsts/store.js +20 -28
- package/dist/hsts/store.js.map +1 -1
- package/dist/hsts/types.d.ts +10 -14
- package/dist/hsts/types.d.ts.map +1 -1
- package/dist/http/alt-svc.d.ts +27 -52
- package/dist/http/alt-svc.d.ts.map +1 -1
- package/dist/http/alt-svc.js +17 -67
- package/dist/http/alt-svc.js.map +1 -1
- package/dist/http/early-hints.d.ts +23 -0
- package/dist/http/early-hints.d.ts.map +1 -0
- package/dist/http/early-hints.js +33 -0
- package/dist/http/early-hints.js.map +1 -0
- package/dist/http/form-data.d.ts +17 -35
- package/dist/http/form-data.d.ts.map +1 -1
- package/dist/http/form-data.js +12 -34
- package/dist/http/form-data.js.map +1 -1
- package/dist/http/h1/client.d.ts +14 -26
- package/dist/http/h1/client.d.ts.map +1 -1
- package/dist/http/h1/client.js +14 -23
- package/dist/http/h1/client.js.map +1 -1
- package/dist/http/h1/encoder.d.ts +21 -17
- package/dist/http/h1/encoder.d.ts.map +1 -1
- package/dist/http/h1/encoder.js +56 -20
- package/dist/http/h1/encoder.js.map +1 -1
- package/dist/http/h1/parser.d.ts +23 -59
- package/dist/http/h1/parser.d.ts.map +1 -1
- package/dist/http/h1/parser.js +61 -55
- package/dist/http/h1/parser.js.map +1 -1
- package/dist/http/h2/client.d.ts +23 -59
- package/dist/http/h2/client.d.ts.map +1 -1
- package/dist/http/h2/client.js +107 -64
- package/dist/http/h2/client.js.map +1 -1
- package/dist/http/h2/frames.d.ts +53 -84
- package/dist/http/h2/frames.d.ts.map +1 -1
- package/dist/http/h2/frames.js +48 -76
- package/dist/http/h2/frames.js.map +1 -1
- package/dist/http/h2/hpack.d.ts +20 -36
- package/dist/http/h2/hpack.d.ts.map +1 -1
- package/dist/http/h2/hpack.js +41 -36
- package/dist/http/h2/hpack.js.map +1 -1
- package/dist/http/negotiator.d.ts +25 -38
- package/dist/http/negotiator.d.ts.map +1 -1
- package/dist/http/negotiator.js +17 -38
- package/dist/http/negotiator.js.map +1 -1
- package/dist/http/pool.d.ts +34 -64
- package/dist/http/pool.d.ts.map +1 -1
- package/dist/http/pool.js +22 -41
- package/dist/http/pool.js.map +1 -1
- package/dist/http/resumable-upload.d.ts +76 -0
- package/dist/http/resumable-upload.d.ts.map +1 -0
- package/dist/http/resumable-upload.js +104 -0
- package/dist/http/resumable-upload.js.map +1 -0
- package/dist/http/trailers.d.ts +29 -0
- package/dist/http/trailers.d.ts.map +1 -0
- package/dist/http/trailers.js +57 -0
- package/dist/http/trailers.js.map +1 -0
- package/dist/index.d.ts +24 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/middleware/circuit-breaker.d.ts +44 -0
- package/dist/middleware/circuit-breaker.d.ts.map +1 -0
- package/dist/middleware/circuit-breaker.js +96 -0
- package/dist/middleware/circuit-breaker.js.map +1 -0
- package/dist/middleware/interceptor.d.ts +13 -32
- package/dist/middleware/interceptor.d.ts.map +1 -1
- package/dist/middleware/interceptor.js +11 -16
- package/dist/middleware/interceptor.js.map +1 -1
- package/dist/middleware/rate-limiter.d.ts +8 -17
- package/dist/middleware/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/rate-limiter.js +11 -12
- package/dist/middleware/rate-limiter.js.map +1 -1
- package/dist/middleware/retry-after.d.ts +15 -0
- package/dist/middleware/retry-after.d.ts.map +1 -0
- package/dist/middleware/retry-after.js +36 -0
- package/dist/middleware/retry-after.js.map +1 -0
- package/dist/middleware/retry.d.ts +9 -18
- package/dist/middleware/retry.d.ts.map +1 -1
- package/dist/middleware/retry.js +12 -9
- package/dist/middleware/retry.js.map +1 -1
- package/dist/proxy/auth.d.ts +73 -0
- package/dist/proxy/auth.d.ts.map +1 -0
- package/dist/proxy/auth.js +129 -0
- package/dist/proxy/auth.js.map +1 -0
- package/dist/proxy/env-proxy.d.ts +5 -15
- package/dist/proxy/env-proxy.d.ts.map +1 -1
- package/dist/proxy/env-proxy.js +5 -23
- package/dist/proxy/env-proxy.js.map +1 -1
- package/dist/proxy/http-proxy.d.ts +12 -19
- package/dist/proxy/http-proxy.d.ts.map +1 -1
- package/dist/proxy/http-proxy.js +5 -8
- package/dist/proxy/http-proxy.js.map +1 -1
- package/dist/proxy/socks.d.ts +13 -20
- package/dist/proxy/socks.d.ts.map +1 -1
- package/dist/proxy/socks.js +8 -10
- package/dist/proxy/socks.js.map +1 -1
- package/dist/sse/parser.d.ts +16 -37
- package/dist/sse/parser.d.ts.map +1 -1
- package/dist/sse/parser.js +31 -28
- package/dist/sse/parser.js.map +1 -1
- package/dist/tls/constants.d.ts +21 -72
- package/dist/tls/constants.d.ts.map +1 -1
- package/dist/tls/constants.js +21 -72
- package/dist/tls/constants.js.map +1 -1
- package/dist/tls/ct.d.ts +78 -0
- package/dist/tls/ct.d.ts.map +1 -0
- package/dist/tls/ct.js +175 -0
- package/dist/tls/ct.js.map +1 -0
- package/dist/tls/early-data.d.ts +45 -0
- package/dist/tls/early-data.d.ts.map +1 -0
- package/dist/tls/early-data.js +46 -0
- package/dist/tls/early-data.js.map +1 -0
- package/dist/tls/ech.d.ts +68 -85
- package/dist/tls/ech.d.ts.map +1 -1
- package/dist/tls/ech.js +54 -102
- package/dist/tls/ech.js.map +1 -1
- package/dist/tls/keylog.d.ts +34 -0
- package/dist/tls/keylog.d.ts.map +1 -0
- package/dist/tls/keylog.js +64 -0
- package/dist/tls/keylog.js.map +1 -0
- package/dist/tls/node-engine.d.ts +10 -17
- package/dist/tls/node-engine.d.ts.map +1 -1
- package/dist/tls/node-engine.js +41 -18
- package/dist/tls/node-engine.js.map +1 -1
- package/dist/tls/ocsp.d.ts +55 -0
- package/dist/tls/ocsp.d.ts.map +1 -0
- package/dist/tls/ocsp.js +131 -0
- package/dist/tls/ocsp.js.map +1 -0
- package/dist/tls/pin-verification.d.ts +5 -4
- package/dist/tls/pin-verification.d.ts.map +1 -1
- package/dist/tls/pin-verification.js +5 -11
- package/dist/tls/pin-verification.js.map +1 -1
- package/dist/tls/session-cache.d.ts +27 -39
- package/dist/tls/session-cache.d.ts.map +1 -1
- package/dist/tls/session-cache.js +20 -24
- package/dist/tls/session-cache.js.map +1 -1
- package/dist/tls/stealth/client-hello.d.ts +26 -45
- package/dist/tls/stealth/client-hello.d.ts.map +1 -1
- package/dist/tls/stealth/client-hello.js +15 -31
- package/dist/tls/stealth/client-hello.js.map +1 -1
- package/dist/tls/stealth/engine.d.ts +10 -15
- package/dist/tls/stealth/engine.d.ts.map +1 -1
- package/dist/tls/stealth/engine.js +98 -18
- package/dist/tls/stealth/engine.js.map +1 -1
- package/dist/tls/stealth/handshake.d.ts +32 -31
- package/dist/tls/stealth/handshake.d.ts.map +1 -1
- package/dist/tls/stealth/handshake.js +74 -47
- package/dist/tls/stealth/handshake.js.map +1 -1
- package/dist/tls/stealth/key-schedule.d.ts +81 -86
- package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
- package/dist/tls/stealth/key-schedule.js +70 -58
- package/dist/tls/stealth/key-schedule.js.map +1 -1
- package/dist/tls/stealth/record-layer.d.ts +52 -75
- package/dist/tls/stealth/record-layer.d.ts.map +1 -1
- package/dist/tls/stealth/record-layer.js +47 -63
- package/dist/tls/stealth/record-layer.js.map +1 -1
- package/dist/tls/stealth/tls12-handshake.d.ts +16 -0
- package/dist/tls/stealth/tls12-handshake.d.ts.map +1 -1
- package/dist/tls/stealth/tls12-handshake.js +10 -2
- package/dist/tls/stealth/tls12-handshake.js.map +1 -1
- package/dist/tls/types.d.ts +46 -60
- package/dist/tls/types.d.ts.map +1 -1
- package/dist/utils/buffer-reader.d.ts +26 -81
- package/dist/utils/buffer-reader.d.ts.map +1 -1
- package/dist/utils/buffer-reader.js +26 -81
- package/dist/utils/buffer-reader.js.map +1 -1
- package/dist/utils/buffer-writer.d.ts +30 -66
- package/dist/utils/buffer-writer.d.ts.map +1 -1
- package/dist/utils/buffer-writer.js +30 -66
- package/dist/utils/buffer-writer.js.map +1 -1
- package/dist/utils/compression.d.ts +18 -0
- package/dist/utils/compression.d.ts.map +1 -0
- package/dist/utils/compression.js +34 -0
- package/dist/utils/compression.js.map +1 -0
- package/dist/utils/dictionary-transport.d.ts +97 -0
- package/dist/utils/dictionary-transport.d.ts.map +1 -0
- package/dist/utils/dictionary-transport.js +171 -0
- package/dist/utils/dictionary-transport.js.map +1 -0
- package/dist/utils/encoding.d.ts +12 -30
- package/dist/utils/encoding.d.ts.map +1 -1
- package/dist/utils/encoding.js +15 -46
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/happy-eyeballs.d.ts +18 -8
- package/dist/utils/happy-eyeballs.d.ts.map +1 -1
- package/dist/utils/happy-eyeballs.js +19 -27
- package/dist/utils/happy-eyeballs.js.map +1 -1
- package/dist/utils/logger.d.ts +54 -81
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +92 -64
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/tcp-fast-open.d.ts +30 -0
- package/dist/utils/tcp-fast-open.d.ts.map +1 -0
- package/dist/utils/tcp-fast-open.js +36 -0
- package/dist/utils/tcp-fast-open.js.map +1 -0
- package/dist/utils/url.d.ts +18 -25
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +18 -25
- package/dist/utils/url.js.map +1 -1
- package/dist/ws/client.d.ts +35 -53
- package/dist/ws/client.d.ts.map +1 -1
- package/dist/ws/client.js +96 -38
- package/dist/ws/client.js.map +1 -1
- package/dist/ws/frame.d.ts +24 -41
- package/dist/ws/frame.d.ts.map +1 -1
- package/dist/ws/frame.js +26 -33
- package/dist/ws/frame.js.map +1 -1
- package/dist/ws/permessage-deflate.d.ts +23 -28
- package/dist/ws/permessage-deflate.d.ts.map +1 -1
- package/dist/ws/permessage-deflate.js +18 -26
- package/dist/ws/permessage-deflate.js.map +1 -1
- package/package.json +2 -2
- package/dist/http/h3/detection.d.ts +0 -17
- package/dist/http/h3/detection.d.ts.map +0 -1
- package/dist/http/h3/detection.js +0 -59
- package/dist/http/h3/detection.js.map +0 -1
package/dist/core/request.d.ts
CHANGED
|
@@ -6,13 +6,11 @@ import type { CacheConfig, CacheMode } from "../cache/types.js";
|
|
|
6
6
|
import type { HSTSConfig } from "../hsts/types.js";
|
|
7
7
|
import type { DNSConfig } from "../dns/types.js";
|
|
8
8
|
import type { ECHOptions } from "../tls/ech.js";
|
|
9
|
+
import type { AuthConfig } from "./auth.js";
|
|
10
|
+
import type { EarlyHintsCallback } from "../http/early-hints.js";
|
|
11
|
+
import type { RequestEncoding } from "../utils/compression.js";
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @typedef {Object} ProgressEvent
|
|
13
|
-
* @property {number} bytes - Bytes transferred so far.
|
|
14
|
-
* @property {number} totalBytes - Total bytes expected (`0` if unknown).
|
|
15
|
-
* @property {number} percent - Completion percentage (`0`–`100`), or `0` if total is unknown.
|
|
13
|
+
* Describes the progress of an upload or download operation.
|
|
16
14
|
*/
|
|
17
15
|
export interface ProgressEvent {
|
|
18
16
|
bytes: number;
|
|
@@ -20,28 +18,18 @@ export interface ProgressEvent {
|
|
|
20
18
|
percent: number;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
|
-
* Callback invoked during
|
|
21
|
+
* Callback invoked during upload or download progress.
|
|
24
22
|
*
|
|
25
23
|
* @callback ProgressCallback
|
|
26
|
-
* @param {ProgressEvent} event -
|
|
24
|
+
* @param {ProgressEvent} event - The current progress snapshot.
|
|
27
25
|
*/
|
|
28
26
|
export type ProgressCallback = (event: ProgressEvent) => void;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @typedef {'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'} HttpMethod
|
|
28
|
+
* Supported HTTP request methods.
|
|
33
29
|
*/
|
|
34
|
-
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
30
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "QUERY";
|
|
35
31
|
/**
|
|
36
|
-
*
|
|
37
|
-
* milliseconds elapsed from request initiation.
|
|
38
|
-
*
|
|
39
|
-
* @typedef {Object} RequestTimings
|
|
40
|
-
* @property {number} dns - Time spent resolving the hostname via DNS.
|
|
41
|
-
* @property {number} connect - Time spent establishing the TCP connection.
|
|
42
|
-
* @property {number} tls - Time spent completing the TLS handshake.
|
|
43
|
-
* @property {number} firstByte - Time from connection open to the first response byte received.
|
|
44
|
-
* @property {number} total - Total wall-clock time for the entire request.
|
|
32
|
+
* Timing measurements for each phase of a request lifecycle, in milliseconds.
|
|
45
33
|
*/
|
|
46
34
|
export interface RequestTimings {
|
|
47
35
|
dns: number;
|
|
@@ -51,14 +39,7 @@ export interface RequestTimings {
|
|
|
51
39
|
total: number;
|
|
52
40
|
}
|
|
53
41
|
/**
|
|
54
|
-
* Per-phase timeout
|
|
55
|
-
* a field means no limit is applied for that phase.
|
|
56
|
-
*
|
|
57
|
-
* @typedef {Object} TimeoutConfig
|
|
58
|
-
* @property {number} [connect] - Maximum milliseconds to establish the TCP connection.
|
|
59
|
-
* @property {number} [tls] - Maximum milliseconds to complete the TLS handshake.
|
|
60
|
-
* @property {number} [response] - Maximum milliseconds to receive the first response byte.
|
|
61
|
-
* @property {number} [total] - Maximum total milliseconds for the whole request.
|
|
42
|
+
* Per-phase timeout thresholds for a request, in milliseconds.
|
|
62
43
|
*/
|
|
63
44
|
export interface TimeoutConfig {
|
|
64
45
|
connect?: number;
|
|
@@ -67,42 +48,12 @@ export interface TimeoutConfig {
|
|
|
67
48
|
total?: number;
|
|
68
49
|
}
|
|
69
50
|
/**
|
|
70
|
-
*
|
|
71
|
-
* plain strings are serialized automatically; raw `Buffer`s and
|
|
72
|
-
* `URLSearchParams` are used verbatim.
|
|
73
|
-
*
|
|
74
|
-
* @typedef {string|Buffer|URLSearchParams|Record<string,unknown>|ReadableStream<Uint8Array>|null} RequestBody
|
|
51
|
+
* Acceptable request body types for outgoing HTTP requests.
|
|
75
52
|
*/
|
|
76
53
|
export type RequestBody = string | Buffer | URLSearchParams | Record<string, unknown> | ReadableStream<Uint8Array> | FormData | null;
|
|
77
54
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* @typedef {Object} NLcURLRequest
|
|
82
|
-
* @property {string} url - Absolute or relative URL to request.
|
|
83
|
-
* @property {HttpMethod} [method='GET'] - HTTP method.
|
|
84
|
-
* @property {Record<string,string>} [headers] - Request headers to merge with session defaults.
|
|
85
|
-
* @property {RequestBody} [body] - Request body payload.
|
|
86
|
-
* @property {number|TimeoutConfig} [timeout] - Timeout in ms (flat) or per-phase config object.
|
|
87
|
-
* @property {AbortSignal} [signal] - Signal used to cancel the request early.
|
|
88
|
-
* @property {string} [impersonate] - Browser profile name (e.g. `"chrome136"`).
|
|
89
|
-
* @property {string} [ja3] - Custom JA3 fingerprint string override.
|
|
90
|
-
* @property {string} [akamai] - Custom Akamai HTTP/2 fingerprint override.
|
|
91
|
-
* @property {boolean} [stealth] - Use the custom stealth TLS engine.
|
|
92
|
-
* @property {boolean} [followRedirects=true] - Follow HTTP redirects automatically.
|
|
93
|
-
* @property {number} [maxRedirects=20] - Maximum number of redirects to follow.
|
|
94
|
-
* @property {boolean} [insecure] - Skip TLS certificate verification.
|
|
95
|
-
* @property {string} [proxy] - Proxy URL (`http://`, `socks4://`, `socks5://`).
|
|
96
|
-
* @property {[string,string]} [proxyAuth] - Proxy credentials as `[username, password]`.
|
|
97
|
-
* @property {'1.1'|'2'} [httpVersion] - Force a specific HTTP protocol version.
|
|
98
|
-
* @property {string} [baseURL] - Base URL prepended to relative `url` values.
|
|
99
|
-
* @property {Record<string,string|number|boolean>} [params] - Query parameters appended to the URL.
|
|
100
|
-
* @property {boolean|string} [cookieJar] - Enable a per-request cookie jar.
|
|
101
|
-
* @property {string} [acceptEncoding] - Override the `Accept-Encoding` header value.
|
|
102
|
-
* @property {string[]} [headerOrder] - Explicit header ordering for fingerprinting.
|
|
103
|
-
* @property {4|6} [dnsFamily] - Force IPv4 (`4`) or IPv6 (`6`) DNS resolution.
|
|
104
|
-
* @property {boolean} [stream] - Return a streaming response body.
|
|
105
|
-
* @property {Logger} [logger] - Logger instance for request-scoped diagnostics.
|
|
55
|
+
* Full request descriptor for a single HTTP request, including URL, method,
|
|
56
|
+
* headers, body, TLS fingerprinting, proxy, caching, and timeout options.
|
|
106
57
|
*/
|
|
107
58
|
export interface NLcURLRequest {
|
|
108
59
|
url: string;
|
|
@@ -120,7 +71,7 @@ export interface NLcURLRequest {
|
|
|
120
71
|
insecure?: boolean;
|
|
121
72
|
proxy?: string;
|
|
122
73
|
proxyAuth?: [string, string];
|
|
123
|
-
httpVersion?: "1.1" | "2"
|
|
74
|
+
httpVersion?: "1.1" | "2";
|
|
124
75
|
baseURL?: string;
|
|
125
76
|
params?: Record<string, string | number | boolean>;
|
|
126
77
|
cookieJar?: boolean | string | CookieJar;
|
|
@@ -130,29 +81,25 @@ export interface NLcURLRequest {
|
|
|
130
81
|
stream?: boolean;
|
|
131
82
|
logger?: Logger;
|
|
132
83
|
tls?: TLSOptions;
|
|
133
|
-
/** DNS-over-HTTPS configuration for this request. Overrides session-level DNS config. */
|
|
134
84
|
dns?: DNSConfig;
|
|
135
|
-
/** Encrypted Client Hello (ECH) options for this request. */
|
|
136
85
|
ech?: ECHOptions;
|
|
137
86
|
onUploadProgress?: ProgressCallback;
|
|
138
87
|
onDownloadProgress?: ProgressCallback;
|
|
139
88
|
throwOnError?: boolean;
|
|
140
|
-
/** HTTP cache mode for this request. Overrides session-level cache config. */
|
|
141
89
|
cache?: CacheMode;
|
|
142
|
-
/**
|
|
143
|
-
* Range header value for partial content requests (RFC 9110 §14).
|
|
144
|
-
* Example: `"bytes=0-499"` or `"bytes=500-999"` or `"bytes=-500"`.
|
|
145
|
-
*/
|
|
146
90
|
range?: string;
|
|
91
|
+
auth?: AuthConfig;
|
|
92
|
+
onEarlyHints?: EarlyHintsCallback;
|
|
93
|
+
expect100Continue?: boolean;
|
|
94
|
+
compressBody?: RequestEncoding;
|
|
95
|
+
methodOverride?: "QUERY";
|
|
96
|
+
/** Block requests to private/reserved IP addresses (SSRF protection). */
|
|
97
|
+
blockPrivateIPs?: boolean;
|
|
98
|
+
/** Block requests to dangerous ports from the WHATWG blocklist. */
|
|
99
|
+
blockDangerousPorts?: boolean;
|
|
147
100
|
}
|
|
148
101
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @typedef {Object} ServerSentEvent
|
|
152
|
-
* @property {string} event - Event type (defaults to `"message"`).
|
|
153
|
-
* @property {string} data - Event data payload.
|
|
154
|
-
* @property {string} id - Last event ID.
|
|
155
|
-
* @property {number|undefined} retry - Reconnection time in ms suggested by the server.
|
|
102
|
+
* Represents a single server-sent event from an SSE stream.
|
|
156
103
|
*/
|
|
157
104
|
export interface ServerSentEvent {
|
|
158
105
|
event: string;
|
|
@@ -161,14 +108,7 @@ export interface ServerSentEvent {
|
|
|
161
108
|
retry?: number;
|
|
162
109
|
}
|
|
163
110
|
/**
|
|
164
|
-
* Configuration for automatic request retry
|
|
165
|
-
*
|
|
166
|
-
* @typedef {Object} RetryConfig
|
|
167
|
-
* @property {number} count - Maximum number of retry attempts after the initial request.
|
|
168
|
-
* @property {number} delay - Base delay in milliseconds between attempts.
|
|
169
|
-
* @property {'linear'|'exponential'} backoff - Strategy for increasing the delay on repeated failures.
|
|
170
|
-
* @property {number} jitter - Maximum random jitter in milliseconds added to each delay.
|
|
171
|
-
* @property {Function} [retryOn] - Optional predicate; return `true` to allow a retry.
|
|
111
|
+
* Configuration for automatic request retry behavior.
|
|
172
112
|
*/
|
|
173
113
|
export interface RetryConfig {
|
|
174
114
|
count: number;
|
|
@@ -178,28 +118,7 @@ export interface RetryConfig {
|
|
|
178
118
|
retryOn?: (error: Error | null, statusCode?: number) => boolean;
|
|
179
119
|
}
|
|
180
120
|
/**
|
|
181
|
-
* Session-level
|
|
182
|
-
* {@link NLcURLSession}. Individual request options always take precedence.
|
|
183
|
-
*
|
|
184
|
-
* @typedef {Object} NLcURLSessionConfig
|
|
185
|
-
* @property {string} [baseURL] - Base URL prepended to relative request URLs.
|
|
186
|
-
* @property {Record<string,string>} [headers] - Headers merged into every request.
|
|
187
|
-
* @property {number|TimeoutConfig} [timeout] - Default timeout applied to all requests.
|
|
188
|
-
* @property {string} [impersonate] - Default browser profile for fingerprinting.
|
|
189
|
-
* @property {string} [ja3] - Default JA3 fingerprint string.
|
|
190
|
-
* @property {string} [akamai] - Default Akamai HTTP/2 fingerprint.
|
|
191
|
-
* @property {boolean} [stealth] - Use the stealth TLS engine by default.
|
|
192
|
-
* @property {string} [proxy] - Default proxy URL.
|
|
193
|
-
* @property {[string,string]} [proxyAuth] - Default proxy credentials.
|
|
194
|
-
* @property {boolean} [followRedirects=true] - Follow redirects by default.
|
|
195
|
-
* @property {number} [maxRedirects=20] - Default maximum redirect count.
|
|
196
|
-
* @property {boolean} [insecure] - Skip TLS verification by default.
|
|
197
|
-
* @property {'1.1'|'2'} [httpVersion] - Force an HTTP protocol version for all requests.
|
|
198
|
-
* @property {boolean|string} [cookieJar] - Persistent cookie jar for the session.
|
|
199
|
-
* @property {Partial<RetryConfig>} [retry] - Automatic retry configuration.
|
|
200
|
-
* @property {string} [acceptEncoding] - Default `Accept-Encoding` header value.
|
|
201
|
-
* @property {4|6} [dnsFamily] - Force IPv4 or IPv6 for DNS resolution.
|
|
202
|
-
* @property {Logger} [logger] - Logger instance for session-scoped diagnostics.
|
|
121
|
+
* Session-level configuration shared across all requests in a session.
|
|
203
122
|
*/
|
|
204
123
|
export interface NLcURLSessionConfig {
|
|
205
124
|
baseURL?: string;
|
|
@@ -214,7 +133,7 @@ export interface NLcURLSessionConfig {
|
|
|
214
133
|
followRedirects?: boolean;
|
|
215
134
|
maxRedirects?: number;
|
|
216
135
|
insecure?: boolean;
|
|
217
|
-
httpVersion?: "1.1" | "2"
|
|
136
|
+
httpVersion?: "1.1" | "2";
|
|
218
137
|
cookieJar?: boolean | string | CookieJar;
|
|
219
138
|
retry?: Partial<RetryConfig>;
|
|
220
139
|
acceptEncoding?: string;
|
|
@@ -224,15 +143,16 @@ export interface NLcURLSessionConfig {
|
|
|
224
143
|
throwOnError?: boolean;
|
|
225
144
|
onUploadProgress?: ProgressCallback;
|
|
226
145
|
onDownloadProgress?: ProgressCallback;
|
|
227
|
-
/** HTTP cache configuration for the session (RFC 9111). */
|
|
228
146
|
cacheConfig?: CacheConfig;
|
|
229
|
-
/** HSTS configuration for the session (RFC 6797). */
|
|
230
147
|
hsts?: HSTSConfig;
|
|
231
|
-
/** DNS-over-HTTPS configuration for the session (RFC 8484). */
|
|
232
148
|
dns?: DNSConfig;
|
|
233
|
-
/** Encrypted Client Hello (ECH) configuration for the session (draft-ietf-tls-esni). */
|
|
234
149
|
ech?: ECHOptions;
|
|
235
|
-
/** Enable Alt-Svc (RFC 7838) for automatic HTTP/3 discovery. @default true */
|
|
236
150
|
altSvc?: boolean;
|
|
151
|
+
auth?: AuthConfig;
|
|
152
|
+
compressBody?: RequestEncoding;
|
|
153
|
+
/** Block requests to private/reserved IP addresses (SSRF protection). */
|
|
154
|
+
blockPrivateIPs?: boolean;
|
|
155
|
+
/** Block requests to dangerous ports from the WHATWG blocklist. */
|
|
156
|
+
blockDangerousPorts?: boolean;
|
|
237
157
|
}
|
|
238
158
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;GAE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AK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,UAAU,CAAC;IAEjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IAEtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,GAAG,CAAC,EAAE,SAAS,CAAC;IAEhB,GAAG,CAAC,EAAE,UAAU,CAAC;IAEjB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,YAAY,CAAC,EAAE,eAAe,CAAC;IAE/B,yEAAyE;IACzE,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
package/dist/core/response.d.ts
CHANGED
|
@@ -1,67 +1,53 @@
|
|
|
1
1
|
import type { RequestTimings, HttpMethod } from "./request.js";
|
|
2
2
|
import type { Readable } from "node:stream";
|
|
3
3
|
/**
|
|
4
|
-
* Metadata about the
|
|
5
|
-
*
|
|
6
|
-
* @typedef {Object} ResponseMeta
|
|
7
|
-
* @property {string} url - The final URL after all redirects.
|
|
8
|
-
* @property {HttpMethod} method - The HTTP method used for the request.
|
|
9
|
-
* @property {Record<string,string>} headers - The request headers that were sent.
|
|
10
|
-
* @property {string} [command] - An optional cURL-equivalent command string for debugging.
|
|
4
|
+
* Metadata about the request that produced a given response.
|
|
11
5
|
*/
|
|
12
6
|
export interface ResponseMeta {
|
|
13
7
|
url: string;
|
|
14
8
|
method: HttpMethod;
|
|
15
9
|
headers: Record<string, string>;
|
|
16
10
|
command?: string;
|
|
11
|
+
tlsVersion?: string;
|
|
12
|
+
tlsCipher?: string;
|
|
13
|
+
alpnProtocol?: string;
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
20
|
-
* convenience accessors for common
|
|
21
|
-
* header inspection.
|
|
16
|
+
* Encapsulates an HTTP response with status, headers, body, timing data,
|
|
17
|
+
* and convenience accessors for common header values and body parsing.
|
|
22
18
|
*
|
|
23
|
-
* @
|
|
19
|
+
* @class
|
|
20
|
+
* @template T - The expected JSON body type.
|
|
24
21
|
*/
|
|
25
22
|
export declare class NLcURLResponse<T = unknown> {
|
|
26
|
-
/** HTTP status code
|
|
23
|
+
/** The HTTP status code. */
|
|
27
24
|
readonly status: number;
|
|
28
|
-
/** HTTP
|
|
25
|
+
/** The HTTP reason phrase. */
|
|
29
26
|
readonly statusText: string;
|
|
30
|
-
/**
|
|
27
|
+
/** Response headers as a case-insensitive key-value map. */
|
|
31
28
|
readonly headers: Record<string, string>;
|
|
32
|
-
/**
|
|
29
|
+
/** Raw header pairs preserving original casing and duplicates. */
|
|
33
30
|
readonly rawHeaders: Array<[string, string]>;
|
|
34
|
-
/**
|
|
31
|
+
/** The full response body as a Buffer. */
|
|
35
32
|
readonly rawBody: Buffer;
|
|
36
|
-
/**
|
|
33
|
+
/** A readable stream for streaming responses, or `null` for buffered responses. */
|
|
37
34
|
readonly body: Readable | null;
|
|
38
|
-
/** HTTP
|
|
35
|
+
/** The negotiated HTTP version (e.g. "1.1", "2"). */
|
|
39
36
|
readonly httpVersion: string;
|
|
40
|
-
/**
|
|
37
|
+
/** The final URL after any redirects. */
|
|
41
38
|
readonly url: string;
|
|
42
|
-
/**
|
|
39
|
+
/** The number of redirects followed to reach this response. */
|
|
43
40
|
readonly redirectCount: number;
|
|
44
|
-
/**
|
|
41
|
+
/** Timing measurements for each request phase. */
|
|
45
42
|
readonly timings: RequestTimings;
|
|
46
43
|
/** Metadata about the originating request. */
|
|
47
44
|
readonly request: ResponseMeta;
|
|
48
45
|
private _json;
|
|
49
46
|
private _text;
|
|
50
47
|
/**
|
|
51
|
-
* Creates a new NLcURLResponse
|
|
48
|
+
* Creates a new NLcURLResponse from the provided initialization fields.
|
|
52
49
|
*
|
|
53
|
-
* @param {Object}
|
|
54
|
-
* @param {number} init.status - HTTP status code.
|
|
55
|
-
* @param {string} init.statusText - HTTP status text.
|
|
56
|
-
* @param {Record<string,string>} init.headers - Normalized response headers.
|
|
57
|
-
* @param {Array<[string,string]>} [init.rawHeaders] - Raw header pairs; defaults to entries of `headers`.
|
|
58
|
-
* @param {Buffer} init.rawBody - Fully buffered response body.
|
|
59
|
-
* @param {Readable|null} [init.body] - Streaming body, or `null`.
|
|
60
|
-
* @param {string} init.httpVersion - Protocol version string.
|
|
61
|
-
* @param {string} init.url - Final URL after redirects.
|
|
62
|
-
* @param {number} init.redirectCount - Number of redirects followed.
|
|
63
|
-
* @param {RequestTimings} init.timings - Lifecycle timing measurements.
|
|
64
|
-
* @param {ResponseMeta} init.request - Originating request metadata.
|
|
50
|
+
* @param {Object} init - Response initialization fields.
|
|
65
51
|
*/
|
|
66
52
|
constructor(init: {
|
|
67
53
|
status: number;
|
|
@@ -77,77 +63,74 @@ export declare class NLcURLResponse<T = unknown> {
|
|
|
77
63
|
request: ResponseMeta;
|
|
78
64
|
});
|
|
79
65
|
/**
|
|
80
|
-
* Returns `true`
|
|
81
|
-
* range, `false` otherwise.
|
|
66
|
+
* Returns `true` if the response status is in the 2xx range.
|
|
82
67
|
*
|
|
83
68
|
* @returns {boolean} Whether the response indicates success.
|
|
84
69
|
*/
|
|
85
70
|
get ok(): boolean;
|
|
86
71
|
/**
|
|
87
|
-
* Decodes the raw body as a UTF-8 string
|
|
88
|
-
* memoized after the first call.
|
|
72
|
+
* Decodes the raw body as a UTF-8 string. Throws if the response is streaming.
|
|
89
73
|
*
|
|
90
|
-
* @returns {string} The response body
|
|
91
|
-
* @throws {Error} If the response
|
|
74
|
+
* @returns {string} The response body as text.
|
|
75
|
+
* @throws {Error} If the response is a streaming response.
|
|
92
76
|
*/
|
|
93
77
|
text(): string;
|
|
94
78
|
/**
|
|
95
|
-
* Parses the
|
|
96
|
-
* memoized after the first call.
|
|
79
|
+
* Parses the response body as JSON. Throws if the response is streaming.
|
|
97
80
|
*
|
|
98
|
-
* @template R -
|
|
99
|
-
* @returns {R} The JSON
|
|
100
|
-
* @throws {Error} If the response
|
|
81
|
+
* @template R - The expected parsed type.
|
|
82
|
+
* @returns {R} The parsed JSON value.
|
|
83
|
+
* @throws {Error} If the response is a streaming response.
|
|
101
84
|
* @throws {SyntaxError} If the body is not valid JSON.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* const data = response.json<{ id: number; name: string }>();
|
|
105
|
-
* console.log(data.id);
|
|
106
85
|
*/
|
|
107
86
|
json<R = T>(): R;
|
|
108
87
|
/**
|
|
109
|
-
* Returns the
|
|
110
|
-
* length when the header is absent or unparseable.
|
|
88
|
+
* Returns the Content-Length header value, or the raw body length as a fallback.
|
|
111
89
|
*
|
|
112
90
|
* @returns {number} The content length in bytes.
|
|
113
91
|
*/
|
|
114
92
|
get contentLength(): number;
|
|
115
93
|
/**
|
|
116
|
-
* Returns the
|
|
117
|
-
* string when the header is absent.
|
|
94
|
+
* Returns the Content-Type header value.
|
|
118
95
|
*
|
|
119
|
-
* @returns {string} The
|
|
96
|
+
* @returns {string} The content type, or an empty string if absent.
|
|
120
97
|
*/
|
|
121
98
|
get contentType(): string;
|
|
122
99
|
/**
|
|
123
|
-
* Returns the
|
|
100
|
+
* Returns the ETag header value, if present.
|
|
101
|
+
*
|
|
102
|
+
* @returns {string|undefined} The entity tag.
|
|
124
103
|
*/
|
|
125
104
|
get etag(): string | undefined;
|
|
126
105
|
/**
|
|
127
|
-
* Returns the
|
|
106
|
+
* Returns the Last-Modified header value, if present.
|
|
107
|
+
*
|
|
108
|
+
* @returns {string|undefined} The last modified date string.
|
|
128
109
|
*/
|
|
129
110
|
get lastModified(): string | undefined;
|
|
130
111
|
/**
|
|
131
|
-
* Returns the
|
|
112
|
+
* Returns the Cache-Control header value, if present.
|
|
113
|
+
*
|
|
114
|
+
* @returns {string|undefined} The cache control directive string.
|
|
132
115
|
*/
|
|
133
116
|
get cacheControl(): string | undefined;
|
|
134
117
|
/**
|
|
135
|
-
* Returns the
|
|
136
|
-
*
|
|
118
|
+
* Returns the Content-Range header value, if present.
|
|
119
|
+
*
|
|
120
|
+
* @returns {string|undefined} The content range descriptor.
|
|
137
121
|
*/
|
|
138
122
|
get contentRange(): string | undefined;
|
|
139
123
|
/**
|
|
140
|
-
* Returns the
|
|
141
|
-
*
|
|
124
|
+
* Returns the Accept-Ranges header value, if present.
|
|
125
|
+
*
|
|
126
|
+
* @returns {string|undefined} The accepted range unit.
|
|
142
127
|
*/
|
|
143
128
|
get acceptRanges(): string | undefined;
|
|
144
129
|
/**
|
|
145
|
-
*
|
|
146
|
-
* supporting multi-value headers such as `Set-Cookie` which are joined
|
|
147
|
-
* when accessed through `headers`.
|
|
130
|
+
* Retrieves all values for a given header name from the raw headers array.
|
|
148
131
|
*
|
|
149
|
-
* @param {string} name - The
|
|
150
|
-
* @returns {string[]} All
|
|
132
|
+
* @param {string} name - The header name (case-insensitive).
|
|
133
|
+
* @returns {string[]} All values for the specified header.
|
|
151
134
|
*/
|
|
152
135
|
getAll(name: string): string[];
|
|
153
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK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