<commit_before>import {Injectable} from '@angular/core';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';

import 'rxjs/add/observable/throw'
import 'rxjs/add/operator/map'
import 'rxjs/add/operator/catch'

import {RestangularHelper} from './ngx-restangular-helper';

@Injectable()
export class RestangularHttp {

  constructor(public http: HttpClient) {
  }

  createRequest(options) {
    let request = RestangularHelper.createRequest(options);

    return this.request(request);
  }

  request(request) {
    return this.http.request(request.method, request.url, {...request, observe: 'response' })
    .map((response: any) => {
      if (!response.ok) {
        return Observable.throw(new HttpErrorResponse(response));
      }
      return response;
    })
    .map(response => {
      response.config = {params: request};
      return response;
    })
    .catch(err => {
      err.request = request;
      err.data = err.error;
      err.repeatRequest = (newRequest?) => {
        return this.request(newRequest || request);
      };

      return Observable.throw(err);
    })
  }
}

<commit_msg>fix(lib): change HttpClient to HttpBackend<commit_after>import { Injectable } from '@angular/core';
import { HttpBackend, HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/filter';

import { RestangularHelper } from './ngx-restangular-helper';

@Injectable()
export class RestangularHttp {

  constructor(public http: HttpBackend) {
  }

  createRequest(options) {
    const request = RestangularHelper.createRequest(options);

    return this.request(request);
  }

  request(request: HttpRequest<any>) {
    return this.http.handle(request)
    .filter(event => event instanceof HttpResponse)
    .map((response: any) => {
      if (!response.ok) {
        return Observable.throw(new HttpErrorResponse(response));
      }
      return response;
    })
    .map(response => {
      response.config = {params: request};
      return response;
    })
    .catch(err => {
      err.request = request;
      err.data = err.error;
      err.repeatRequest = (newRequest?) => {
        return this.request(newRequest || request);
      };

      return Observable.throw(err);
    })
  }
}


{'fraction_non_alphanumeric': 0.1373827965756217, 'fraction_numerical': 0.0, 'mean_word_length': 3.374331550802139, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1048026', 'n_tokens_mistral': 733, 'n_tokens_neox': 727, 'n_words': 149}