Repository: angular
Issue: HttpClient should allow different responseTypes for success response and error response
Labels: feature,freq2: medium,area: common/http,feature: under consideration

## I'm submitting a...
<!-- Check one of the following options with "x" -->
<pre><code>
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre>

## Current behavior
Currently, HttpClient expects the same responseType for both, success responses as well as error responses. This brings up issues when a WEB API returns e. g. JSON but just an (non JSON based) error string in the case of an error.

## Expected behavior
<!-- Describe what the desired behavior would be. -->
In see two solutions: Provide an own errorResponseType field or assign the received message as a string when JSON parsing does not work (as a fallback)

## Minimal reproduction of the problem with instructions
The following test case is using such an Web API. It returns json for the success case and plain text in the case of an error. Both tests lead to an 400 error due to validation issues. In the first case where we are requesting plain text, the text based error message is shown; in the second case where we are requesting json (which would be the case if the call succeeded) we are just getting null.
```
import { TestBed } from '@angular/core/testing';
import { HttpClient, HttpClientModule, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';

fdescribe('Different responseTypes for success and error case', () => {

  let http: HttpTestingController;
  let httpClient: HttpClient;

  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [ HttpClientModule ]
    });

    httpClient = TestBed.get(HttpClient);
  });

  it('should send an HttpErrorResponse where the error property is the received body', (complete: Function) => {
    let actualBody;
    httpClient.post('http://www.angular.at/api/flight', {}, { responseType: 'text' }).subscribe(null, (resp: HttpErrorResponse) => {
      actualBody = resp.error;
      expect(actualBody).not.toBeNull();
      complete();
    });
  });

  it('should send an HttpErrorResponse where the error property is the body of the flushed response', (complete: Function) => {
    let actualBody;
    httpClient.post('http://www.angular.at/api/flight', {}, { responseType: 'json' }).subscribe(null, (resp: HttpErrorResponse) => {
      actualBody = resp.error;
      expect(actualBody).not.toBeNull();
      complete();
    });
  });

});
```

## What is the motivation / use case for changing the behavior?
<!-- Describe the motivation or the concrete use case. -->
Using existing Web APIs more seamlessly 

## Environment

<pre><code>
Angular version: 4.3
<!-- Check whether this is still an issue in the most recent Angular version -->

For Tooling issues:
- Platform:  Windows