1 /// <reference types="node" />
2 import * as http2 from 'http2';
3 export declare type MetadataValue = string | Buffer;
4 export declare type MetadataObject = Map<string, MetadataValue[]>;
6 * A class for storing metadata. Keys are normalized to lowercase ASCII.
8 export declare class Metadata {
9 protected internalRepr: MetadataObject;
11 * Sets the given value for the given key by replacing any other values
12 * associated with that key. Normalizes the key.
13 * @param key The key to whose value should be set.
14 * @param value The value to set. Must be a buffer if and only
15 * if the normalized key ends with '-bin'.
17 set(key: string, value: MetadataValue): void;
19 * Adds the given value for the given key by appending to a list of previous
20 * values associated with that key. Normalizes the key.
21 * @param key The key for which a new value should be appended.
22 * @param value The value to add. Must be a buffer if and only
23 * if the normalized key ends with '-bin'.
25 add(key: string, value: MetadataValue): void;
27 * Removes the given key and any associated values. Normalizes the key.
28 * @param key The key whose values should be removed.
30 remove(key: string): void;
32 * Gets a list of all values associated with the key. Normalizes the key.
33 * @param key The key whose value should be retrieved.
34 * @return A list of values associated with the given key.
36 get(key: string): MetadataValue[];
38 * Gets a plain object mapping each key to the first value associated with it.
39 * This reflects the most common way that people will want to see metadata.
40 * @return A key/value mapping of the metadata.
43 [key: string]: MetadataValue;
46 * Clones the metadata object.
47 * @return The newly cloned object.
51 * Merges all key-value pairs from a given Metadata object into this one.
52 * If both this object and the given object have values in the same key,
53 * values from the other Metadata object will be appended to this object's
55 * @param other A Metadata object.
57 merge(other: Metadata): void;
59 * Creates an OutgoingHttpHeaders object that can be used with the http2 API.
61 toHttp2Headers(): http2.OutgoingHttpHeaders;
62 private _getCoreRepresentation;
64 * Returns a new Metadata object based fields in a given IncomingHttpHeaders
66 * @param headers An IncomingHttpHeaders object.
68 static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata;