aurelia / aurelia/http-client

response Type is set to wrong one(json) when the actual response is a string with Content-Type "text/plain"

Open
#155 3 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
60
Forks
57
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a bug report**
- **Library Version:**
0.11.0

**Please tell us about your environment:**
- **Operating System:**
Windows [7] professional
- **Node Version:**
4.6.1


- **NPM Version:**
3.8.9


- **JSPM OR Webpack AND Version**
JSPM 0.16.32


- **Browser:**
IE 11
- **Language:**
ESNext(ES - 6), angularjs

**Current behavior:**
In IE-11 the headers.headers['Content-Type'] of HttpResponseMessage is always being undefined. So the response type is set to wrong one(json), Even if I am getting the response from the server as a string with content-type text/plain. So getting "invalid character" Error when tried to parse the string response#151

```
if (this.responseType === 'json') {
this._content = JSON.parse(this.response, this.reviver);
return this._content;
}
```

**Expected/desired behavior:**

- **What is the expected behavior?**
It should not parse the response when the response is a string with content-type text/plain. So as to prevent the "Invalid character" error in IE-11.
- **What is the motivation / use case for changing the behavior?**

Contributor guide

Open the contributing guide

Research direction

Start by tracing the responseType selection and the shown JSON.parse path in the HttpResponseMessage response handling, focusing on how IE 11 exposes the Content-Type header. Reproduce a text/plain response containing a string and verify that it is returned without JSON parsing, while JSON responses retain their existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.