Just look at the source for HttpModule. You'll see all the providers required to create the Http
. Most of those providers were what were in the now removed HTTP_PROVIDERS
export function _createDefaultCookieXSRFStrategy() {
return new CookieXSRFStrategy();
}
export function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http {
return new Http(xhrBackend, requestOptions);
}
@NgModule({
providers: [
{provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions]},
BrowserXhr,
{provide: RequestOptions, useClass: BaseRequestOptions},
{provide: ResponseOptions, useClass: BaseResponseOptions},
XHRBackend,
{provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy},
],
})
export class HttpModule {
}
Just add everything in the above providers
to the array you pass to ReflectiveInjector.resolveAndCreate
.
If your goal is to get the Http
before bootstrap, there's another little thing you need to take care of, which is the CookieXSRFStrategy
. It will not work prior to bootstrapping, as it is dependendent on some platform browser stuff. You can just replace it with a noop, as mentioned in this post