Skip to content

Commit

Permalink
Merge pull request #156 from derekpitt/empty-response
Browse files Browse the repository at this point in the history
fix(http-response-message): handle empty responses
  • Loading branch information
EisenbergEffect authored Nov 8, 2016
2 parents 27a84bb + bae5188 commit f44c814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/http-response-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class HttpResponseMessage {
return this._content;
}

if (this.response === undefined || this.response === null) {
if (this.response === undefined || this.response === null || this.response == '') {
this._content = this.response;
return this._content;
}
Expand Down
5 changes: 5 additions & 0 deletions test/http-response-message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ describe("HttpResponseMessage", () => {
expect(httpResponse.content).toBeNull();
});

it("will return a blank string if response is blank", () => {
let httpResponse = new HttpResponseMessage(null, {response: '',responseText:''});
expect(httpResponse.content).toBe('');
});

it("will JSON.parse if the response type is 'json'", () => {
let response = {}, reviver = {}, content = {};
let parseSpy = spyOn(JSON, 'parse').and.returnValue(content);
Expand Down

0 comments on commit f44c814

Please sign in to comment.