1 |
|
2 |
|
3 |
|
4 | import * as http2 from 'http2';
|
5 | export type MetadataValue = string | Buffer;
|
6 | export type MetadataObject = Map<string, MetadataValue[]>;
|
7 | export interface MetadataOptions {
|
8 | idempotentRequest?: boolean;
|
9 | waitForReady?: boolean;
|
10 | cacheableRequest?: boolean;
|
11 | corked?: boolean;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 | export declare class Metadata {
|
17 | protected internalRepr: MetadataObject;
|
18 | private options;
|
19 | constructor(options?: MetadataOptions);
|
20 | /**
|
21 | * Sets the given value for the given key by replacing any other values
|
22 | * associated with that key. Normalizes the key.
|
23 | * @param key The key to whose value should be set.
|
24 | * @param value The value to set. Must be a buffer if and only
|
25 | * if the normalized key ends with '-bin'.
|
26 | */
|
27 | set(key: string, value: MetadataValue): void;
|
28 | /**
|
29 | * Adds the given value for the given key by appending to a list of previous
|
30 | * values associated with that key. Normalizes the key.
|
31 | * @param key The key for which a new value should be appended.
|
32 | * @param value The value to add. Must be a buffer if and only
|
33 | * if the normalized key ends with '-bin'.
|
34 | */
|
35 | add(key: string, value: MetadataValue): void;
|
36 | /**
|
37 | * Removes the given key and any associated values. Normalizes the key.
|
38 | * @param key The key whose values should be removed.
|
39 | */
|
40 | remove(key: string): void;
|
41 | /**
|
42 | * Gets a list of all values associated with the key. Normalizes the key.
|
43 | * @param key The key whose value should be retrieved.
|
44 | * @return A list of values associated with the given key.
|
45 | */
|
46 | get(key: string): MetadataValue[];
|
47 | /**
|
48 | * Gets a plain object mapping each key to the first value associated with it.
|
49 | * This reflects the most common way that people will want to see metadata.
|
50 | * @return A key/value mapping of the metadata.
|
51 | */
|
52 | getMap(): {
|
53 | [key: string]: MetadataValue;
|
54 | };
|
55 | |
56 |
|
57 |
|
58 |
|
59 | clone(): Metadata;
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | merge(other: Metadata): void;
|
68 | setOptions(options: MetadataOptions): void;
|
69 | getOptions(): MetadataOptions;
|
70 | |
71 |
|
72 |
|
73 | toHttp2Headers(): http2.OutgoingHttpHeaders;
|
74 | |
75 |
|
76 |
|
77 |
|
78 | toJSON(): {
|
79 | [key: string]: MetadataValue[];
|
80 | };
|
81 | |
82 |
|
83 |
|
84 |
|
85 |
|
86 | static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata;
|
87 | }
|