2017-09-13 19:42:16 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
|
|
|
|
import { WebResource } from "./webResource";
|
2018-05-14 20:49:05 +03:00
|
|
|
import { HttpHeaders } from "./httpHeaders";
|
2017-09-13 19:42:16 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-16 19:06:26 +03:00
|
|
|
* The properties on an HTTP response which will always be present.
|
2017-09-13 19:42:16 +03:00
|
|
|
*/
|
2018-08-16 19:06:26 +03:00
|
|
|
export interface HttpResponse {
|
2017-09-13 19:42:16 +03:00
|
|
|
/**
|
|
|
|
* The raw request
|
|
|
|
*/
|
|
|
|
request: WebResource;
|
2018-05-14 20:49:05 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The HTTP response status (e.g. 200)
|
|
|
|
*/
|
|
|
|
status: number;
|
|
|
|
|
2017-09-13 19:42:16 +03:00
|
|
|
/**
|
2018-05-14 20:49:05 +03:00
|
|
|
* The HTTP response headers.
|
2017-09-13 19:42:16 +03:00
|
|
|
*/
|
2018-05-14 20:49:05 +03:00
|
|
|
headers: HttpHeaders;
|
2018-08-16 19:06:26 +03:00
|
|
|
}
|
2018-05-14 20:49:05 +03:00
|
|
|
|
2018-08-23 02:16:40 +03:00
|
|
|
declare global {
|
|
|
|
/**
|
|
|
|
* Stub declaration of the browser-only Blob type.
|
|
|
|
* Full type information can be obtained by including "lib": ["dom"] in tsconfig.json.
|
|
|
|
*/
|
|
|
|
interface Blob {}
|
|
|
|
}
|
|
|
|
|
2018-08-16 19:06:26 +03:00
|
|
|
/**
|
|
|
|
* Wrapper object for http request and response. Deserialized object is stored in
|
|
|
|
* the `parsedBody` property when the response body is received in JSON or XML.
|
|
|
|
*/
|
|
|
|
export interface HttpOperationResponse extends HttpResponse {
|
2018-05-23 00:27:03 +03:00
|
|
|
/**
|
|
|
|
* The parsed HTTP response headers.
|
|
|
|
*/
|
2018-08-16 19:06:26 +03:00
|
|
|
parsedHeaders?: { [key: string]: any };
|
2018-05-23 00:27:03 +03:00
|
|
|
|
2017-09-13 19:42:16 +03:00
|
|
|
/**
|
|
|
|
* The response body as text (string format)
|
|
|
|
*/
|
2018-03-27 03:54:26 +03:00
|
|
|
bodyAsText?: string | null;
|
|
|
|
|
2017-09-13 19:42:16 +03:00
|
|
|
/**
|
2018-03-27 03:54:26 +03:00
|
|
|
* The response body as parsed JSON or XML
|
2017-09-13 19:42:16 +03:00
|
|
|
*/
|
2018-08-16 19:06:26 +03:00
|
|
|
parsedBody?: any;
|
2018-05-14 20:49:05 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-16 19:06:26 +03:00
|
|
|
* BROWSER ONLY
|
|
|
|
*
|
|
|
|
* The response body as a browser Blob.
|
2018-05-14 20:49:05 +03:00
|
|
|
* Always undefined in node.js.
|
|
|
|
*/
|
2018-08-29 20:16:55 +03:00
|
|
|
blobBody?: Promise<Blob>;
|
2018-05-14 20:49:05 +03:00
|
|
|
|
|
|
|
/**
|
2018-08-16 19:06:26 +03:00
|
|
|
* NODEJS ONLY
|
|
|
|
*
|
2018-05-14 20:49:05 +03:00
|
|
|
* The response body as a node.js Readable stream.
|
|
|
|
* Always undefined in the browser.
|
|
|
|
*/
|
|
|
|
readableStreamBody?: NodeJS.ReadableStream;
|
2017-09-13 19:42:16 +03:00
|
|
|
}
|
2018-08-29 20:16:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The flattened response to a REST call.
|
|
|
|
* Contains the underlying HttpOperationResponse as well as
|
|
|
|
* the merged properties of the parsedBody, parsedHeaders, etc.
|
|
|
|
*/
|
|
|
|
export interface RestResponse {
|
|
|
|
/**
|
|
|
|
* The underlying HTTP response containing both raw and deserialized response data.
|
|
|
|
*/
|
|
|
|
_response: HttpOperationResponse;
|
|
|
|
|
|
|
|
[key: string]: any;
|
|
|
|
}
|