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";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper object for http request and response. Deserialized object is stored in
|
2018-04-03 02:57:42 +03:00
|
|
|
* the `parsedBody` property when the response body is received in JSON or XML.
|
2017-09-13 19:42:16 +03:00
|
|
|
* @class
|
|
|
|
* Initializes a new instance of the HttpOperationResponse class.
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
export class HttpOperationResponse {
|
|
|
|
/**
|
|
|
|
* The raw request
|
|
|
|
*/
|
|
|
|
request: WebResource;
|
|
|
|
/**
|
2017-10-25 20:30:16 +03:00
|
|
|
* The raw response. Please use the response directly when the response body is a ReadableStream.
|
2017-09-13 19:42:16 +03:00
|
|
|
*/
|
|
|
|
response: Response;
|
|
|
|
/**
|
|
|
|
* 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-04-03 02:57:42 +03:00
|
|
|
parsedBody?: { [key: string]: any } | Array<any> | string | number | boolean | null | void;
|
2017-09-13 19:42:16 +03:00
|
|
|
|
2017-10-25 20:30:16 +03:00
|
|
|
constructor(request: WebResource, response: Response) {
|
2017-09-13 19:42:16 +03:00
|
|
|
/**
|
|
|
|
* Reference to the original request object.
|
|
|
|
* [WebResource] object.
|
|
|
|
* @type {object}
|
|
|
|
*/
|
|
|
|
this.request = request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reference to the original response object.
|
|
|
|
* [ServerResponse] object.
|
|
|
|
* @type {object}
|
|
|
|
*/
|
|
|
|
this.response = response;
|
2017-10-25 20:30:16 +03:00
|
|
|
/* tslint:disable:no-null-keyword */
|
2017-09-13 19:42:16 +03:00
|
|
|
this.bodyAsText = null;
|
2018-04-03 02:57:42 +03:00
|
|
|
this.parsedBody = null;
|
2017-09-13 19:42:16 +03:00
|
|
|
}
|
|
|
|
}
|