@angular/http
Version:
Angular - the http service
90 lines (89 loc) • 3.28 kB
TypeScript
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Observable } from 'rxjs';
import { ResponseOptions } from '../base_response_options';
import { ReadyState } from '../enums';
import { Connection, ConnectionBackend, XSRFStrategy } from '../interfaces';
import { Request } from '../static_request';
import { Response } from '../static_response';
import { BrowserXhr } from './browser_xhr';
/**
* Creates connections using `XMLHttpRequest`. Given a fully-qualified
* request, an `XHRConnection` will immediately create an `XMLHttpRequest` object and send the
* request.
*
* This class would typically not be created or interacted with directly inside applications, though
* the {@link MockConnection} may be interacted with in tests.
*
* @deprecated see https://angular.io/guide/http
* @publicApi
*/
export declare class XHRConnection implements Connection {
request: Request;
/**
* Response {@link EventEmitter} which emits a single {@link Response} value on load event of
* `XMLHttpRequest`.
*/
response: Observable<Response>;
readyState: ReadyState;
constructor(req: Request, browserXHR: BrowserXhr, baseResponseOptions?: ResponseOptions);
setDetectedContentType(req: any /** TODO Request */, _xhr: any /** XMLHttpRequest */): void;
}
/**
* `XSRFConfiguration` sets up Cross Site Request Forgery (XSRF) protection for the application
* using a cookie. See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)
* for more information on XSRF.
*
* Applications can configure custom cookie and header names by binding an instance of this class
* with different `cookieName` and `headerName` values. See the main HTTP documentation for more
* details.
*
* @deprecated see https://angular.io/guide/http
* @publicApi
*/
export declare class CookieXSRFStrategy implements XSRFStrategy {
private _cookieName;
private _headerName;
constructor(_cookieName?: string, _headerName?: string);
configureRequest(req: Request): void;
}
/**
* Creates {@link XHRConnection} instances.
*
* This class would typically not be used by end users, but could be
* overridden if a different backend implementation should be used,
* such as in a node backend.
*
* @usageNotes
* ### Example
*
* ```
* import {Http, MyNodeBackend, HTTP_PROVIDERS, BaseRequestOptions} from '@angular/http';
* @Component({
* viewProviders: [
* HTTP_PROVIDERS,
* {provide: Http, useFactory: (backend, options) => {
* return new Http(backend, options);
* }, deps: [MyNodeBackend, BaseRequestOptions]}]
* })
* class MyComponent {
* constructor(http:Http) {
* http.request('people.json').subscribe(res => this.people = res.json());
* }
* }
* ```
* @deprecated see https://angular.io/guide/http
* @publicApi
*/
export declare class XHRBackend implements ConnectionBackend {
private _browserXHR;
private _baseResponseOptions;
private _xsrfStrategy;
constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy);
createConnection(request: Request): XHRConnection;
}