@angular/common/http#HttpXhrBackend TypeScript Examples

The following examples show how to use @angular/common/http#HttpXhrBackend. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ns-http-backend.ts    From nativescript-http with MIT License 6 votes vote down vote up
@Injectable()
export class NsHttpBackEnd extends HttpXhrBackend {
    constructor(xhrFactory: NSHTTPXhr, private nsFileSystem: NSFileSystem) {
        super(xhrFactory);
    }

    handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {
        let result: Observable<HttpEvent<any>>;

        if (isLocalRequest(req.url)) {
            result = this.handleLocalFileRequest(req.url);
        } else {
            result = super.handle(req);
        }

        return result;
    }

    private handleLocalFileRequest(url: string): Observable<HttpEvent<any>> {
        return processLocalFileRequest(
            url,
            this.nsFileSystem,
            createSuccessResponse,
            createErrorResponse
        );
    }
}
Example #2
Source File: ns-http-backend.d.ts    From nativescript-http with MIT License 5 votes vote down vote up
export declare class NsHttpBackEnd extends HttpXhrBackend {
    private nsFileSystem;
    constructor(xhrFactory: NSHTTPXhr, nsFileSystem: NSFileSystem);
    handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
    private handleLocalFileRequest;
    static ɵfac: i0.ɵɵFactoryDeclaration<NsHttpBackEnd, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<NsHttpBackEnd>;
}
Example #3
Source File: ns-http-backend.d.ts    From nativescript-plugins with Apache License 2.0 5 votes vote down vote up
export declare class NsHttpBackEnd extends HttpXhrBackend {
    private nsFileSystem;
    constructor(xhrFactory: NSHTTPXhr, nsFileSystem: NSFileSystem);
    handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
    private handleLocalFileRequest;
    static ɵfac: i0.ɵɵFactoryDef<NsHttpBackEnd, never>;
    static ɵprov: i0.ɵɵInjectableDef<NsHttpBackEnd>;
}