UNPKG

3.43 kBTypeScriptView Raw
1import { AbortSignal } from "./abort";
2/**
3 * @public
4 *
5 * A collection of key/value pairs with case-insensitive keys.
6 */
7export interface Headers extends Map<string, string> {
8 /**
9 * Returns a new instance of Headers with the specified header set to the
10 * provided value. Does not modify the original Headers instance.
11 *
12 * @param headerName - The name of the header to add or overwrite
13 * @param headerValue - The value to which the header should be set
14 */
15 withHeader(headerName: string, headerValue: string): Headers;
16 /**
17 * Returns a new instance of Headers without the specified header. Does not
18 * modify the original Headers instance.
19 *
20 * @param headerName - The name of the header to remove
21 */
22 withoutHeader(headerName: string): Headers;
23}
24/**
25 * @public
26 *
27 * A mapping of header names to string values. Multiple values for the same
28 * header should be represented as a single string with values separated by
29 * `, `.
30 *
31 * Keys should be considered case insensitive, even if this is not enforced by a
32 * particular implementation. For example, given the following HeaderBag, where
33 * keys differ only in case:
34 *
35 * ```json
36 * {
37 * 'x-amz-date': '2000-01-01T00:00:00Z',
38 * 'X-Amz-Date': '2001-01-01T00:00:00Z'
39 * }
40 * ```
41 *
42 * The SDK may at any point during processing remove one of the object
43 * properties in favor of the other. The headers may or may not be combined, and
44 * the SDK will not deterministically select which header candidate to use.
45 */
46export type HeaderBag = Record<string, string>;
47/**
48 * @public
49 *
50 * Represents an HTTP message with headers and an optional static or streaming
51 * body. bode: ArrayBuffer | ArrayBufferView | string | Uint8Array | Readable | ReadableStream;
52 */
53export interface HttpMessage {
54 headers: HeaderBag;
55 body?: any;
56}
57/**
58 * @public
59 *
60 * A mapping of query parameter names to strings or arrays of strings, with the
61 * second being used when a parameter contains a list of values. Value can be set
62 * to null when query is not in key-value pairs shape
63 */
64export type QueryParameterBag = Record<string, string | Array<string> | null>;
65/**
66 * @public
67 *
68 * @deprecated use {@link EndpointV2} from `@aws-sdk/types`.
69 */
70export interface Endpoint {
71 protocol: string;
72 hostname: string;
73 port?: number;
74 path: string;
75 query?: QueryParameterBag;
76}
77/**
78 * @public
79 *
80 * Interface an HTTP request class. Contains
81 * addressing information in addition to standard message properties.
82 */
83export interface HttpRequest extends HttpMessage, Endpoint {
84 method: string;
85}
86/**
87 * @public
88 *
89 * Represents an HTTP message as received in reply to a request. Contains a
90 * numeric status code in addition to standard message properties.
91 */
92export interface HttpResponse extends HttpMessage {
93 statusCode: number;
94}
95/**
96 * @public
97 *
98 * Represents HTTP message whose body has been resolved to a string. This is
99 * used in parsing http message.
100 */
101export interface ResolvedHttpResponse extends HttpResponse {
102 body: string;
103}
104/**
105 * @public
106 *
107 * Represents the options that may be passed to an Http Handler.
108 */
109export interface HttpHandlerOptions {
110 abortSignal?: AbortSignal;
111 /**
112 * The maximum time in milliseconds that the connection phase of a request
113 * may take before the connection attempt is abandoned.
114 */
115 requestTimeout?: number;
116}