UNPKG

1.54 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * HTTP request body used by both {@link Request} and {@link Response}
10 * https://fetch.spec.whatwg.org/#body
11 */
12export declare abstract class Body {
13 /**
14 * Attempts to return body as parsed `JSON` object, or raises an exception.
15 */
16 json(): any;
17 /**
18 * Returns the body as a string, presuming `toString()` can be called on the response body.
19 *
20 * When decoding an `ArrayBuffer`, the optional `encodingHint` parameter determines how the
21 * bytes in the buffer will be interpreted. Valid values are:
22 *
23 * - `legacy` - incorrectly interpret the bytes as UTF-16 (technically, UCS-2). Only characters
24 * in the Basic Multilingual Plane are supported, surrogate pairs are not handled correctly.
25 * In addition, the endianness of the 16-bit octet pairs in the `ArrayBuffer` is not taken
26 * into consideration. This is the default behavior to avoid breaking apps, but should be
27 * considered deprecated.
28 *
29 * - `iso-8859` - interpret the bytes as ISO-8859 (which can be used for ASCII encoded text).
30 */
31 text(encodingHint?: 'legacy' | 'iso-8859'): string;
32 /**
33 * Return the body as an ArrayBuffer
34 */
35 arrayBuffer(): ArrayBuffer;
36 /**
37 * Returns the request's body as a Blob, assuming that body exists.
38 */
39 blob(): Blob;
40}