File size: 11,049 Bytes
31e8457
051bada
 
 
 
 
 
 
31e8457
 
 
 
 
 
 
 
 
 
051bada
31e8457
051bada
31e8457
 
 
 
051bada
 
 
31e8457
 
 
 
051bada
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
 
 
051bada
 
 
 
31e8457
 
 
 
051bada
 
31e8457
051bada
31e8457
 
 
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
 
051bada
 
 
 
 
 
31e8457
051bada
31e8457
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/**
 * Models HTTP headers for the unstable HTTP client and server modules.
 *
 * `Headers` values are immutable maps keyed by lowercase header name. This
 * module converts common header inputs into that shape, provides helpers for
 * reading and updating header values, and redacts configured sensitive headers
 * when values are inspected.
 *
 * @since 4.0.0
 */
import * as Context from "../../Context.ts";
import * as Equ from "../../Equivalence.ts";
import * as Option from "../../Option.ts";
import * as Record from "../../Record.ts";
import * as Redactable from "../../Redactable.ts";
import * as Redacted from "../../Redacted.ts";
import * as Schema from "../../Schema.ts";
/**
 * Runtime type identifier for `Headers` values.
 *
 * @category type IDs
 * @since 4.0.0
 */
export declare const TypeId: unique symbol;
/**
 * Type of the unique symbol used to brand `Headers` values.
 *
 * @category type IDs
 * @since 4.0.0
 */
export type TypeId = typeof TypeId;
/**
 * Returns `true` if the provided value is a `Headers` value.
 *
 * @category refinements
 * @since 4.0.0
 */
export declare const isHeaders: (u: unknown) => u is Headers;
/**
 * Represents an immutable HTTP header collection keyed by lowercase header name.
 *
 * **Details**
 *
 * `Headers` values also support redaction through the `Redactable` protocol.
 *
 * @category models
 * @since 4.0.0
 */
export interface Headers extends Redactable.Redactable {
    readonly [TypeId]: TypeId;
    readonly [key: string]: string;
}
/**
 * Provides an `Equivalence` instance that compares `Headers` by header names
 * and string values.
 *
 * @category instances
 * @since 4.0.0
 */
export declare const Equivalence: Equ.Equivalence<Headers>;
/**
 * Schema interface for `Headers` values encoded as records of string header values.
 *
 * @category schemas
 * @since 4.0.0
 */
export interface HeadersSchema extends Schema.declare<Headers, {
    readonly [x: string]: string;
}> {
}
/**
 * Schema for `Headers` values encoded as records of string header values.
 *
 * **Details**
 *
 * Decoding normalizes header names through `fromInput`; encoding returns a plain record.
 *
 * @category schemas
 * @since 4.0.0
 */
export declare const HeadersSchema: HeadersSchema;
/**
 * Input accepted when constructing headers.
 *
 * **Details**
 *
 * Records may contain string values, string arrays, or `undefined`; arrays are joined with `", "`, and `undefined` values are omitted.
 *
 * @category models
 * @since 4.0.0
 */
export type Input = Record.ReadonlyRecord<string, string | ReadonlyArray<string> | undefined> | Iterable<readonly [string, string]>;
/**
 * An empty `Headers` collection.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const empty: Headers;
/**
 * Creates `Headers` from a record or iterable of header entries.
 *
 * **Details**
 *
 * Header names are normalized to lowercase. Array values in record input are joined with `", "`, and `undefined` values are omitted.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const fromInput: (input?: Input) => Headers;
/**
 * Treats an existing record as `Headers` unsafely.
 *
 * **Gotchas**
 *
 * This mutates the record's prototype and does not normalize header names; callers must provide the expected lowercase keys.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const fromRecordUnsafe: (input: Record.ReadonlyRecord<string, string>) => Headers;
/**
 * Returns `true` when a header with the given name is present.
 *
 * **Details**
 *
 * The lookup lowercases the provided header name.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const has: {
    /**
     * Returns `true` when a header with the given name is present.
     *
     * **Details**
     *
     * The lookup lowercases the provided header name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (key: string): (self: Headers) => boolean;
    /**
     * Returns `true` when a header with the given name is present.
     *
     * **Details**
     *
     * The lookup lowercases the provided header name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, key: string): boolean;
};
/**
 * Gets a header value by name safely.
 *
 * **Details**
 *
 * The lookup lowercases the provided header name and returns `Option.none()` when absent.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const get: {
    /**
     * Gets a header value by name safely.
     *
     * **Details**
     *
     * The lookup lowercases the provided header name and returns `Option.none()` when absent.
     *
     * @category combinators
     * @since 4.0.0
     */
    (key: string): (self: Headers) => Option.Option<string>;
    /**
     * Gets a header value by name safely.
     *
     * **Details**
     *
     * The lookup lowercases the provided header name and returns `Option.none()` when absent.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, key: string): Option.Option<string>;
};
/**
 * Returns a new `Headers` collection with the given header set.
 *
 * **Details**
 *
 * The header name is normalized to lowercase.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const set: {
    /**
     * Returns a new `Headers` collection with the given header set.
     *
     * **Details**
     *
     * The header name is normalized to lowercase.
     *
     * @category combinators
     * @since 4.0.0
     */
    (key: string, value: string): (self: Headers) => Headers;
    /**
     * Returns a new `Headers` collection with the given header set.
     *
     * **Details**
     *
     * The header name is normalized to lowercase.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, key: string, value: string): Headers;
};
/**
 * Returns a new `Headers` collection with all provided headers set.
 *
 * **Details**
 *
 * Input headers are normalized with `fromInput` and override existing headers with the same lowercase name.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const setAll: {
    /**
     * Returns a new `Headers` collection with all provided headers set.
     *
     * **Details**
     *
     * Input headers are normalized with `fromInput` and override existing headers with the same lowercase name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (headers: Input): (self: Headers) => Headers;
    /**
     * Returns a new `Headers` collection with all provided headers set.
     *
     * **Details**
     *
     * Input headers are normalized with `fromInput` and override existing headers with the same lowercase name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, headers: Input): Headers;
};
/**
 * Returns a new `Headers` collection containing headers from both collections.
 *
 * **Details**
 *
 * Headers from the second collection override headers from the first collection with the same name.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const merge: {
    /**
     * Returns a new `Headers` collection containing headers from both collections.
     *
     * **Details**
     *
     * Headers from the second collection override headers from the first collection with the same name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (headers: Headers): (self: Headers) => Headers;
    /**
     * Returns a new `Headers` collection containing headers from both collections.
     *
     * **Details**
     *
     * Headers from the second collection override headers from the first collection with the same name.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, headers: Headers): Headers;
};
/**
 * Returns a new `Headers` collection with the named header removed.
 *
 * **Details**
 *
 * The provided header name is normalized to lowercase before removal.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const remove: {
    /**
     * Returns a new `Headers` collection with the named header removed.
     *
     * **Details**
     *
     * The provided header name is normalized to lowercase before removal.
     *
     * @category combinators
     * @since 4.0.0
     */
    (key: string): (self: Headers) => Headers;
    /**
     * Returns a new `Headers` collection with the named header removed.
     *
     * **Details**
     *
     * The provided header name is normalized to lowercase before removal.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, key: string): Headers;
};
/**
 * Returns a new `Headers` collection with each named header removed.
 *
 * **Details**
 *
 * Each provided header name is normalized to lowercase before removal.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const removeMany: {
    /**
     * Returns a new `Headers` collection with each named header removed.
     *
     * **Details**
     *
     * Each provided header name is normalized to lowercase before removal.
     *
     * @category combinators
     * @since 4.0.0
     */
    (keys: Iterable<string>): (self: Headers) => Headers;
    /**
     * Returns a new `Headers` collection with each named header removed.
     *
     * **Details**
     *
     * Each provided header name is normalized to lowercase before removal.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, keys: Iterable<string>): Headers;
};
/**
 * Returns a plain record with selected header values wrapped in `Redacted`.
 *
 * **Details**
 *
 * String keys are normalized to lowercase before matching; regular expressions are tested against the stored header names.
 *
 * @category combinators
 * @since 4.0.0
 */
export declare const redact: {
    /**
     * Returns a plain record with selected header values wrapped in `Redacted`.
     *
     * **Details**
     *
     * String keys are normalized to lowercase before matching; regular expressions are tested against the stored header names.
     *
     * @category combinators
     * @since 4.0.0
     */
    (key: string | RegExp | ReadonlyArray<string | RegExp>): (self: Headers) => Record<string, string | Redacted.Redacted>;
    /**
     * Returns a plain record with selected header values wrapped in `Redacted`.
     *
     * **Details**
     *
     * String keys are normalized to lowercase before matching; regular expressions are tested against the stored header names.
     *
     * @category combinators
     * @since 4.0.0
     */
    (self: Headers, key: string | RegExp | ReadonlyArray<string | RegExp>): Record<string, string | Redacted.Redacted>;
};
/**
 * Context reference listing header names or patterns that should be redacted when `Headers` are inspected or rendered.
 *
 * **Details**
 *
 * Defaults include `authorization`, `cookie`, `set-cookie`, and `x-api-key`.
 *
 * @category fiber refs
 * @since 4.0.0
 */
export declare const CurrentRedactedNames: Context.Reference<readonly (string | RegExp)[]>;
//# sourceMappingURL=Headers.d.ts.map