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