fix(platform-server): provide XhrFactory for HttpClient
This commit is contained in:
@ -11,7 +11,7 @@ const xhr2: any = require('xhr2');
|
||||
import {Injectable, Optional, Provider} from '@angular/core';
|
||||
import {BrowserXhr, Connection, ConnectionBackend, Http, ReadyState, Request, RequestOptions, Response, XHRBackend, XSRFStrategy} from '@angular/http';
|
||||
|
||||
import {HttpClient, HttpRequest, HttpHandler, HttpInterceptor, HttpResponse, HTTP_INTERCEPTORS, HttpBackend, XhrFactory, ɵinterceptingHandler as interceptingHandler} from '@angular/common/http';
|
||||
import {HttpClient, HttpEvent, HttpRequest, HttpHandler, HttpInterceptor, HttpResponse, HTTP_INTERCEPTORS, HttpBackend, XhrFactory, ɵinterceptingHandler as interceptingHandler} from '@angular/common/http';
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observer} from 'rxjs/Observer';
|
||||
@ -143,12 +143,12 @@ export class ZoneMacroTaskBackend implements ConnectionBackend {
|
||||
}
|
||||
|
||||
export class ZoneClientBackend extends
|
||||
ZoneMacroTaskWrapper<HttpRequest<any>, HttpResponse<any>> implements HttpBackend {
|
||||
ZoneMacroTaskWrapper<HttpRequest<any>, HttpEvent<any>> implements HttpBackend {
|
||||
constructor(private backend: HttpBackend) { super(); }
|
||||
|
||||
handle(request: HttpRequest<any>): Observable<HttpResponse<any>> { return this.wrap(request); }
|
||||
handle(request: HttpRequest<any>): Observable<HttpEvent<any>> { return this.wrap(request); }
|
||||
|
||||
protected delegate(request: HttpRequest<any>): Observable<HttpResponse<any>> {
|
||||
protected delegate(request: HttpRequest<any>): Observable<HttpEvent<any>> {
|
||||
return this.backend.handle(request);
|
||||
}
|
||||
}
|
||||
@ -167,7 +167,7 @@ export function zoneWrappedInterceptingHandler(
|
||||
export const SERVER_HTTP_PROVIDERS: Provider[] = [
|
||||
{provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions]},
|
||||
{provide: BrowserXhr, useClass: ServerXhr}, {provide: XSRFStrategy, useClass: ServerXsrfStrategy},
|
||||
{
|
||||
{provide: XhrFactory, useClass: ServerXhr}, {
|
||||
provide: HttpHandler,
|
||||
useFactory: zoneWrappedInterceptingHandler,
|
||||
deps: [HttpBackend, [new Optional(), HTTP_INTERCEPTORS]]
|
||||
|
Reference in New Issue
Block a user