UNPKG

2.27 kBTypeScriptView Raw
1/// <reference types="node" />
2import { WebResourceLike } from "./webResource";
3import { HttpHeadersLike } from "./httpHeaders";
4/**
5 * The properties on an HTTP response which will always be present.
6 */
7export interface HttpResponse {
8 /**
9 * The raw request
10 */
11 request: WebResourceLike;
12 /**
13 * The HTTP response status (e.g. 200)
14 */
15 status: number;
16 /**
17 * The HTTP response headers.
18 */
19 headers: HttpHeadersLike;
20}
21declare global {
22 /**
23 * Stub declaration of the browser-only Blob type.
24 * Full type information can be obtained by including "lib": ["dom"] in tsconfig.json.
25 */
26 interface Blob {
27 }
28}
29/**
30 * Wrapper object for http request and response. Deserialized object is stored in
31 * the `parsedBody` property when the response body is received in JSON or XML.
32 */
33export interface HttpOperationResponse extends HttpResponse {
34 /**
35 * The parsed HTTP response headers.
36 */
37 parsedHeaders?: {
38 [key: string]: any;
39 };
40 /**
41 * The response body as text (string format)
42 */
43 bodyAsText?: string | null;
44 /**
45 * The response body as parsed JSON or XML
46 */
47 parsedBody?: any;
48 /**
49 * BROWSER ONLY
50 *
51 * The response body as a browser Blob.
52 * Always undefined in node.js.
53 */
54 blobBody?: Promise<Blob>;
55 /**
56 * NODEJS ONLY
57 *
58 * The response body as a node.js Readable stream.
59 * Always undefined in the browser.
60 */
61 readableStreamBody?: NodeJS.ReadableStream;
62 /**
63 * The redirected property indicates whether the response is the result of a request which was redirected.
64 */
65 redirected?: boolean;
66 /**
67 * The url property contains the URL of the response. The value will be the final URL obtained after any redirects.
68 */
69 url?: string;
70}
71/**
72 * The flattened response to a REST call.
73 * Contains the underlying HttpOperationResponse as well as
74 * the merged properties of the parsedBody, parsedHeaders, etc.
75 */
76export interface RestResponse {
77 /**
78 * The underlying HTTP response containing both raw and deserialized response data.
79 */
80 _response: HttpOperationResponse;
81 [key: string]: any;
82}
83//# sourceMappingURL=httpOperationResponse.d.ts.map
\No newline at end of file