2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2015-07-28 13:10:25 -07:00
|
|
|
/**
|
|
|
|
* @module
|
|
|
|
* @description
|
|
|
|
* The http module provides services to perform http requests. To get started, see the {@link Http}
|
|
|
|
* class.
|
|
|
|
*/
|
2016-07-27 13:09:05 -07:00
|
|
|
import {NgModule} from '@angular/core';
|
2016-06-08 16:38:52 -07:00
|
|
|
|
2016-08-30 18:07:40 -07:00
|
|
|
import {BrowserJsonp} from './backends/browser_jsonp';
|
|
|
|
import {BrowserXhr} from './backends/browser_xhr';
|
2017-09-12 20:45:02 +02:00
|
|
|
import {JSONPBackend} from './backends/jsonp_backend';
|
2016-08-30 18:07:40 -07:00
|
|
|
import {CookieXSRFStrategy, XHRBackend} from './backends/xhr_backend';
|
|
|
|
import {BaseRequestOptions, RequestOptions} from './base_request_options';
|
|
|
|
import {BaseResponseOptions, ResponseOptions} from './base_response_options';
|
|
|
|
import {Http, Jsonp} from './http';
|
|
|
|
import {XSRFStrategy} from './interfaces';
|
2015-07-28 13:10:25 -07:00
|
|
|
|
2016-06-28 11:31:35 -07:00
|
|
|
|
2016-07-27 13:09:05 -07:00
|
|
|
export function _createDefaultCookieXSRFStrategy() {
|
|
|
|
return new CookieXSRFStrategy();
|
|
|
|
}
|
2016-06-27 12:27:23 -07:00
|
|
|
|
2016-06-01 14:58:11 -07:00
|
|
|
export function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http {
|
2016-06-02 17:30:40 -07:00
|
|
|
return new Http(xhrBackend, requestOptions);
|
|
|
|
}
|
|
|
|
|
2016-08-13 03:30:12 +09:00
|
|
|
export function jsonpFactory(jsonpBackend: JSONPBackend, requestOptions: RequestOptions): Jsonp {
|
2016-06-02 17:30:40 -07:00
|
|
|
return new Jsonp(jsonpBackend, requestOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-27 13:09:05 -07:00
|
|
|
/**
|
|
|
|
* The module that includes http's providers
|
|
|
|
*
|
2018-06-01 22:09:01 +02:00
|
|
|
* @deprecated see https://angular.io/guide/http
|
2018-10-19 17:47:13 +01:00
|
|
|
* @publicApi
|
2016-07-27 13:09:05 -07:00
|
|
|
*/
|
2016-08-18 15:01:07 -07:00
|
|
|
@NgModule({
|
|
|
|
providers: [
|
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
{provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions]},
|
|
|
|
BrowserXhr,
|
|
|
|
{provide: RequestOptions, useClass: BaseRequestOptions},
|
|
|
|
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
|
|
|
XHRBackend,
|
|
|
|
{provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy},
|
|
|
|
],
|
|
|
|
})
|
2016-07-27 13:09:05 -07:00
|
|
|
export class HttpModule {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The module that includes jsonp's providers
|
|
|
|
*
|
2019-03-12 08:29:00 -04:00
|
|
|
* @deprecated see https://angular.io/api/common/http/HttpClient#jsonp
|
2018-10-19 17:47:13 +01:00
|
|
|
* @publicApi
|
2016-07-27 13:09:05 -07:00
|
|
|
*/
|
2016-08-18 15:01:07 -07:00
|
|
|
@NgModule({
|
|
|
|
providers: [
|
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
{provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions]},
|
|
|
|
BrowserJsonp,
|
|
|
|
{provide: RequestOptions, useClass: BaseRequestOptions},
|
|
|
|
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
2017-09-12 20:45:02 +02:00
|
|
|
JSONPBackend,
|
2016-08-18 15:01:07 -07:00
|
|
|
],
|
|
|
|
})
|
2016-07-27 13:09:05 -07:00
|
|
|
export class JsonpModule {
|
|
|
|
}
|