title: Http Request retry mechanism in Angular 4?
body: <p>I am trying to implement a request/response intercept mechanism in Angular4 .I am fairly new to observables.</p>
  
  <p>I maintain two interceptor array , one for request and other for response. Interceptors are nothing but functions which accept request/response object and transforms them.</p>
  
  <pre><code>sendRequest(req:Response):Observable&lt;Response&gt;{
      req= this.processRequest(req);
  
      This.http.request(req)
             .map( (res:Response)=&gt;{
                  return this.processResponse(res)
              })
              .catch(this.handleError)
  }
  
  handleError(err:Response):Observable&lt;Response&gt;{
      return Observable.throw(err);
  }
  </code></pre>
  
  <p>Basic error handling works fine .  Sometimes for a 401 exception , I want to get new Auth token and retry the same request with updated Auth token. </p>
  
  <p>What I am thinking is to introduce array of error interceptor. One of the error  interceptor function  would check if it is 401 and would issue a new refresh request to server ,invalidating subsequent error interceptor functions .  I assume there is a need to switch the observable stream. The observer will eventually get response from latest request made. How to proceed on this?</p>