{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.fixRequestBody = void 0;\nvar querystring = require(\"querystring\");\n/**\n * Fix proxied body if bodyParser is involved.\n */\nfunction fixRequestBody(proxyReq, req) {\n  // skip fixRequestBody() when req.readableLength not 0 (bodyParser failure)\n  if (req.readableLength !== 0) {\n    return;\n  }\n  var requestBody = req.body;\n  if (!requestBody) {\n    return;\n  }\n  var contentType = proxyReq.getHeader('Content-Type');\n  if (!contentType) {\n    return;\n  }\n  var writeBody = function writeBody(bodyData) {\n    // deepcode ignore ContentLengthInCode: bodyParser fix\n    proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));\n    proxyReq.write(bodyData);\n  };\n  if (contentType.includes('application/json')) {\n    writeBody(JSON.stringify(requestBody));\n  } else if (contentType.includes('application/x-www-form-urlencoded')) {\n    writeBody(querystring.stringify(requestBody));\n  }\n}\nexports.fixRequestBody = fixRequestBody;","map":{"version":3,"names":["Object","defineProperty","exports","value","fixRequestBody","querystring","require","proxyReq","req","readableLength","requestBody","body","contentType","getHeader","writeBody","bodyData","setHeader","Buffer","byteLength","write","includes","JSON","stringify"],"sources":["D:/DSP_Management/node_modules/http-proxy-middleware/dist/handlers/fix-request-body.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.fixRequestBody = void 0;\nconst querystring = require(\"querystring\");\n/**\n * Fix proxied body if bodyParser is involved.\n */\nfunction fixRequestBody(proxyReq, req) {\n    // skip fixRequestBody() when req.readableLength not 0 (bodyParser failure)\n    if (req.readableLength !== 0) {\n        return;\n    }\n    const requestBody = req.body;\n    if (!requestBody) {\n        return;\n    }\n    const contentType = proxyReq.getHeader('Content-Type');\n    if (!contentType) {\n        return;\n    }\n    const writeBody = (bodyData) => {\n        // deepcode ignore ContentLengthInCode: bodyParser fix\n        proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));\n        proxyReq.write(bodyData);\n    };\n    if (contentType.includes('application/json')) {\n        writeBody(JSON.stringify(requestBody));\n    }\n    else if (contentType.includes('application/x-www-form-urlencoded')) {\n        writeBody(querystring.stringify(requestBody));\n    }\n}\nexports.fixRequestBody = fixRequestBody;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,cAAc,GAAG,KAAK,CAAC;AAC/B,IAAMC,WAAW,GAAGC,OAAO,CAAC,aAAa,CAAC;AAC1C;AACA;AACA;AACA,SAASF,cAAcA,CAACG,QAAQ,EAAEC,GAAG,EAAE;EACnC;EACA,IAAIA,GAAG,CAACC,cAAc,KAAK,CAAC,EAAE;IAC1B;EACJ;EACA,IAAMC,WAAW,GAAGF,GAAG,CAACG,IAAI;EAC5B,IAAI,CAACD,WAAW,EAAE;IACd;EACJ;EACA,IAAME,WAAW,GAAGL,QAAQ,CAACM,SAAS,CAAC,cAAc,CAAC;EACtD,IAAI,CAACD,WAAW,EAAE;IACd;EACJ;EACA,IAAME,SAAS,GAAG,SAAZA,SAASA,CAAIC,QAAQ,EAAK;IAC5B;IACAR,QAAQ,CAACS,SAAS,CAAC,gBAAgB,EAAEC,MAAM,CAACC,UAAU,CAACH,QAAQ,CAAC,CAAC;IACjER,QAAQ,CAACY,KAAK,CAACJ,QAAQ,CAAC;EAC5B,CAAC;EACD,IAAIH,WAAW,CAACQ,QAAQ,CAAC,kBAAkB,CAAC,EAAE;IAC1CN,SAAS,CAACO,IAAI,CAACC,SAAS,CAACZ,WAAW,CAAC,CAAC;EAC1C,CAAC,MACI,IAAIE,WAAW,CAACQ,QAAQ,CAAC,mCAAmC,CAAC,EAAE;IAChEN,SAAS,CAACT,WAAW,CAACiB,SAAS,CAACZ,WAAW,CAAC,CAAC;EACjD;AACJ;AACAR,OAAO,CAACE,cAAc,GAAGA,cAAc","ignoreList":[]},"metadata":{},"sourceType":"script","externalDependencies":[]}