| 7 | const common = require('./common') |
| 8 | |
| 9 | function parseJSONRequestBody(req, requestBody) { |
| 10 | if (!requestBody || !common.isJSONContent(req.headers)) { |
| 11 | return requestBody |
| 12 | } |
| 13 | |
| 14 | if (common.contentEncoding(req.headers, 'gzip')) { |
| 15 | requestBody = String(zlib.gunzipSync(Buffer.from(requestBody, 'hex'))) |
| 16 | } else if (common.contentEncoding(req.headers, 'deflate')) { |
| 17 | requestBody = String(zlib.inflateSync(Buffer.from(requestBody, 'hex'))) |
| 18 | } |
| 19 | |
| 20 | return JSON.parse(requestBody) |
| 21 | } |
| 22 | |
| 23 | function parseFullReplyResult(response, fullReplyResult) { |
| 24 | debug('full response from callback result: %j', fullReplyResult) |