Skip to content

Commit

Permalink
fix: for Service#request, always provide parsed body (#139)
Browse files Browse the repository at this point in the history
PR-URL: #139
  • Loading branch information
kjin authored May 14, 2018
1 parent e68b33b commit 4637b33
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ export class Util {
const parsedResp = extend(
true, {err: err || null}, resp && util.parseHttpRespMessage(resp),
body && util.parseHttpRespBody(body));
// Assign the parsed body to resp.body, even if { json: false } was passed
// as a request option.
// We assume that nobody uses the previously unparsed value of resp.body.
if (!parsedResp.err && resp && typeof parsedResp.body === 'object') {
parsedResp.resp.body = parsedResp.body;
}

callback(parsedResp.err, parsedResp.body, parsedResp.resp);
}
Expand Down

0 comments on commit 4637b33

Please sign in to comment.