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