UNPKG

2.45 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 */
8import { ResponseOptions } from './base_response_options';
9import { Body } from './body';
10import { ResponseType } from './enums';
11import { Headers } from './headers';
12/**
13 * Creates `Response` instances from provided values.
14 *
15 * Though this object isn't
16 * usually instantiated by end-users, it is the primary object interacted with when it comes time to
17 * add data to a view.
18 *
19 * @usageNotes
20 * ### Example
21 *
22 * ```
23 * http.request('my-friends.txt').subscribe(response => this.friends = response.text());
24 * ```
25 *
26 * The Response's interface is inspired by the Response constructor defined in the [Fetch
27 * Spec](https://fetch.spec.whatwg.org/#response-class), but is considered a static value whose body
28 * can be accessed many times. There are other differences in the implementation, but this is the
29 * most significant.
30 *
31 * @deprecated see https://angular.io/guide/http
32 * @publicApi
33 */
34export declare class Response extends Body {
35 /**
36 * One of "basic", "cors", "default", "error", or "opaque".
37 *
38 * Defaults to "default".
39 */
40 type: ResponseType;
41 /**
42 * True if the response's status is within 200-299
43 */
44 ok: boolean;
45 /**
46 * URL of response.
47 *
48 * Defaults to empty string.
49 */
50 url: string;
51 /**
52 * Status code returned by server.
53 *
54 * Defaults to 200.
55 */
56 status: number;
57 /**
58 * Text representing the corresponding reason phrase to the `status`, as defined in [ietf rfc 2616
59 * section 6.1.1](https://tools.ietf.org/html/rfc2616#section-6.1.1)
60 *
61 * Defaults to "OK"
62 */
63 statusText: string | null;
64 /**
65 * Non-standard property
66 *
67 * Denotes how many of the response body's bytes have been loaded, for example if the response is
68 * the result of a progress event.
69 */
70 bytesLoaded: number;
71 /**
72 * Non-standard property
73 *
74 * Denotes how many bytes are expected in the final response body.
75 */
76 totalBytes: number;
77 /**
78 * Headers object based on the `Headers` class in the [Fetch
79 * Spec](https://fetch.spec.whatwg.org/#headers-class).
80 */
81 headers: Headers | null;
82 constructor(responseOptions: ResponseOptions);
83 toString(): string;
84}