MCPcopy
hub / github.com/angular/angular / TestInterceptor

Class TestInterceptor

packages/common/http/test/module_spec.ts:25–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23const IS_INTERCEPTOR_C_ENABLED = new HttpContextToken<boolean | undefined>(() => undefined);
24
25class TestInterceptor implements HttpInterceptor {
26 constructor(private value: string) {}
27
28 intercept(req: HttpRequest<any>, delegate: HttpHandler): Observable<HttpEvent<any>> {
29 const existing = req.headers.get('Intercepted');
30 const next = !!existing ? existing + ',' + this.value : this.value;
31 req = req.clone({setHeaders: {'Intercepted': next}});
32 return delegate.handle(req).pipe(
33 map((event) => {
34 if (event instanceof HttpResponse) {
35 const existing = event.headers.get('Intercepted');
36 const next = !!existing ? existing + ',' + this.value : this.value;
37 return event.clone({headers: event.headers.set('Intercepted', next)});
38 }
39 return event;
40 }),
41 );
42 }
43}
44
45class InterceptorA extends TestInterceptor {
46 constructor() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…