fix(platform-server): avoid dependency cycle when using http interceptor (#24229)
Fixes #23023. When a HTTP Interceptor injects HttpClient it causes a DI cycle. This fix is to use Injector to lazily inject HTTP_INTERCEPTORS while setting up the HttpHandler on the server so as to break the cycle. PR Close #24229
This commit is contained in:

committed by
Victor Berchet

parent
b18cf21e99
commit
2991b1b217
@ -11,7 +11,7 @@ export {HttpClient} from './src/client';
|
||||
export {HttpHeaders} from './src/headers';
|
||||
export {HTTP_INTERCEPTORS, HttpInterceptor} from './src/interceptor';
|
||||
export {JsonpClientBackend, JsonpInterceptor} from './src/jsonp';
|
||||
export {HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, interceptingHandler as ɵinterceptingHandler} from './src/module';
|
||||
export {HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpInterceptingHandler as ɵHttpInterceptingHandler} from './src/module';
|
||||
export {HttpParameterCodec, HttpParams, HttpUrlEncodingCodec} from './src/params';
|
||||
export {HttpRequest} from './src/request';
|
||||
export {HttpDownloadProgressEvent, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpResponseBase, HttpSentEvent, HttpUserEvent} from './src/response';
|
||||
|
@ -42,23 +42,6 @@ export class HttpInterceptingHandler implements HttpHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an `HttpHandler` that applies a bunch of `HttpInterceptor`s
|
||||
* to a request before passing it to the given `HttpBackend`.
|
||||
*
|
||||
* Meant to be used as a factory function within `HttpClientModule`.
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function interceptingHandler(
|
||||
backend: HttpBackend, interceptors: HttpInterceptor[] | null = []): HttpHandler {
|
||||
if (!interceptors) {
|
||||
return backend;
|
||||
}
|
||||
return interceptors.reduceRight(
|
||||
(next, interceptor) => new HttpInterceptorHandler(next, interceptor), backend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory function that determines where to store JSONP callbacks.
|
||||
*
|
||||
|
Reference in New Issue
Block a user