Makes HTTPResponse serializable (#2143)

* Use the callback body instead of response.body that may not be set

* Adds test to handle undefined responses

* Adds toJSON method to properly serialize HTTPResponse

* Use ES5 defineProperty to make keys enumerable

* removes body key from serialization

* Indent nits
This commit is contained in:
Florent Vilmart
2016-06-25 13:56:02 -04:00
committed by Tyler Brock
parent 35b4c063fb
commit 3e413683f7
3 changed files with 122 additions and 16 deletions

View File

@@ -62,7 +62,7 @@ module.exports = function(options) {
}
return promise.reject(error);
}
let httpResponse = new HTTPResponse(response);
let httpResponse = new HTTPResponse(response, body);
// Consider <200 && >= 400 as errors
if (httpResponse.status < 200 || httpResponse.status >= 400) {