UNPKG

3.28 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 { Observable } from 'rxjs';
9import { ResponseOptions } from '../base_response_options';
10import { ReadyState } from '../enums';
11import { Connection, ConnectionBackend, XSRFStrategy } from '../interfaces';
12import { Request } from '../static_request';
13import { Response } from '../static_response';
14import { BrowserXhr } from './browser_xhr';
15/**
16 * Creates connections using `XMLHttpRequest`. Given a fully-qualified
17 * request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
18 * request.
19 *
20 * This class would typically not be created or interacted with directly inside applications, though
21 * the {@link MockConnection} may be interacted with in tests.
22 *
23 * @deprecated see https://angular.io/guide/http
24 * @publicApi
25 */
26export declare class XHRConnection implements Connection {
27 request: Request;
28 /**
29 * Response {@link EventEmitter} which emits a single {@link Response} value on load event of
30 * `XMLHttpRequest`.
31 */
32 response: Observable<Response>;
33 readyState: ReadyState;
34 constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions);
35 setDetectedContentType(req: any /** TODO Request */, _xhr: any /** XMLHttpRequest */): void;
36}
37/**
38 * `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
39 * using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
40 * for more information on XSRF.
41 *
42 * Applications can configure custom cookie and header names by binding an instance of this class
43 * with different `cookieName` and `headerName` values. See the main HTTP documentation for more
44 * details.
45 *
46 * @deprecated see https://angular.io/guide/http
47 * @publicApi
48 */
49export declare class CookieXSRFStrategy implements XSRFStrategy {
50 private _cookieName;
51 private _headerName;
52 constructor(_cookieName?: string, _headerName?: string);
53 configureRequest(req: Request): void;
54}
55/**
56 * Creates {@link XHRConnection} instances.
57 *
58 * This class would typically not be used by end users, but could be
59 * overridden if a different backend implementation should be used,
60 * such as in a node backend.
61 *
62 * @usageNotes
63 * ### Example
64 *
65 * ```
66 * import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http';
67 * @Component({
68 * viewProviders: [
69 * HTTP_PROVIDERS,
70 * {provide: Http, useFactory: (backend, options) => {
71 * return new Http(backend, options);
72 * }, deps: [MyNodeBackend, BaseRequestOptions]}]
73 * })
74 * class MyComponent {
75 * constructor(http:Http) {
76 * http.request('people.json').subscribe(res => this.people = res.json());
77 * }
78 * }
79 * ```
80 * @deprecated see https://angular.io/guide/http
81 * @publicApi
82 */
83export declare class XHRBackend implements ConnectionBackend {
84 private _browserXHR;
85 private _baseResponseOptions;
86 private _xsrfStrategy;
87 constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy);
88 createConnection(request: Request): XHRConnection;
89}