MCPcopy Create free account
hub / github.com/nock/nock / parseJSONRequestBody

Function parseJSONRequestBody

lib/playback_interceptor.js:9–21  ·  view source on GitHub ↗
(req, requestBody)

Source from the content-addressed store, hash-verified

7const common = require('./common')
8
9function 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
23function parseFullReplyResult(response, fullReplyResult) {
24 debug('full response from callback result: %j', fullReplyResult)

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected