{"ast":null,"code":"var url = require('url'),\n  common = require('../common');\nvar redirectRegex = /^201|30(1|2|7|8)$/;\n\n/*!\n * Array of passes.\n *\n * A `pass` is just a function that is executed on `req, res, options`\n * so that you can easily add new checks while still keeping the base\n * flexible.\n */\n\nmodule.exports = {\n  // <--\n\n  /**\n   * If is a HTTP 1.0 request, remove chunk headers\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  removeChunked: function removeChunked(req, res, proxyRes) {\n    if (req.httpVersion === '1.0') {\n      delete proxyRes.headers['transfer-encoding'];\n    }\n  },\n  /**\n   * If is a HTTP 1.0 request, set the correct connection header\n   * or if connection header not present, then use `keep-alive`\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  setConnection: function setConnection(req, res, proxyRes) {\n    if (req.httpVersion === '1.0') {\n      proxyRes.headers.connection = req.headers.connection || 'close';\n    } else if (req.httpVersion !== '2.0' && !proxyRes.headers.connection) {\n      proxyRes.headers.connection = req.headers.connection || 'keep-alive';\n    }\n  },\n  setRedirectHostRewrite: function setRedirectHostRewrite(req, res, proxyRes, options) {\n    if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite) && proxyRes.headers['location'] && redirectRegex.test(proxyRes.statusCode)) {\n      var target = url.parse(options.target);\n      var u = url.parse(proxyRes.headers['location']);\n\n      // make sure the redirected host matches the target host before rewriting\n      if (target.host != u.host) {\n        return;\n      }\n      if (options.hostRewrite) {\n        u.host = options.hostRewrite;\n      } else if (options.autoRewrite) {\n        u.host = req.headers['host'];\n      }\n      if (options.protocolRewrite) {\n        u.protocol = options.protocolRewrite;\n      }\n      proxyRes.headers['location'] = u.format();\n    }\n  },\n  /**\n   * Copy headers from proxyResponse to response\n   * set each header in response object.\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   * @param {Object} Options options.cookieDomainRewrite: Config to rewrite cookie domain\n   *\n   * @api private\n   */\n  writeHeaders: function writeHeaders(req, res, proxyRes, options) {\n    var rewriteCookieDomainConfig = options.cookieDomainRewrite,\n      rewriteCookiePathConfig = options.cookiePathRewrite,\n      preserveHeaderKeyCase = options.preserveHeaderKeyCase,\n      rawHeaderKeyMap,\n      setHeader = function setHeader(key, header) {\n        if (header == undefined) return;\n        if (rewriteCookieDomainConfig && key.toLowerCase() === 'set-cookie') {\n          header = common.rewriteCookieProperty(header, rewriteCookieDomainConfig, 'domain');\n        }\n        if (rewriteCookiePathConfig && key.toLowerCase() === 'set-cookie') {\n          header = common.rewriteCookieProperty(header, rewriteCookiePathConfig, 'path');\n        }\n        res.setHeader(String(key).trim(), header);\n      };\n    if (typeof rewriteCookieDomainConfig === 'string') {\n      //also test for ''\n      rewriteCookieDomainConfig = {\n        '*': rewriteCookieDomainConfig\n      };\n    }\n    if (typeof rewriteCookiePathConfig === 'string') {\n      //also test for ''\n      rewriteCookiePathConfig = {\n        '*': rewriteCookiePathConfig\n      };\n    }\n\n    // message.rawHeaders is added in: v0.11.6\n    // https://nodejs.org/api/http.html#http_message_rawheaders\n    if (preserveHeaderKeyCase && proxyRes.rawHeaders != undefined) {\n      rawHeaderKeyMap = {};\n      for (var i = 0; i < proxyRes.rawHeaders.length; i += 2) {\n        var key = proxyRes.rawHeaders[i];\n        rawHeaderKeyMap[key.toLowerCase()] = key;\n      }\n    }\n    Object.keys(proxyRes.headers).forEach(function (key) {\n      var header = proxyRes.headers[key];\n      if (preserveHeaderKeyCase && rawHeaderKeyMap) {\n        key = rawHeaderKeyMap[key] || key;\n      }\n      setHeader(key, header);\n    });\n  },\n  /**\n   * Set the statusCode from the proxyResponse\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  writeStatusCode: function writeStatusCode(req, res, proxyRes) {\n    // From Node.js docs: response.writeHead(statusCode[, statusMessage][, headers])\n    if (proxyRes.statusMessage) {\n      res.statusCode = proxyRes.statusCode;\n      res.statusMessage = proxyRes.statusMessage;\n    } else {\n      res.statusCode = proxyRes.statusCode;\n    }\n  }\n};","map":{"version":3,"names":["url","require","common","redirectRegex","module","exports","removeChunked","req","res","proxyRes","httpVersion","headers","setConnection","connection","setRedirectHostRewrite","options","hostRewrite","autoRewrite","protocolRewrite","test","statusCode","target","parse","u","host","protocol","format","writeHeaders","rewriteCookieDomainConfig","cookieDomainRewrite","rewriteCookiePathConfig","cookiePathRewrite","preserveHeaderKeyCase","rawHeaderKeyMap","setHeader","key","header","undefined","toLowerCase","rewriteCookieProperty","String","trim","rawHeaders","i","length","Object","keys","forEach","writeStatusCode","statusMessage"],"sources":["D:/DSP_Management/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js"],"sourcesContent":["var url    = require('url'),\n    common = require('../common');\n\n\nvar redirectRegex = /^201|30(1|2|7|8)$/;\n\n/*!\n * Array of passes.\n *\n * A `pass` is just a function that is executed on `req, res, options`\n * so that you can easily add new checks while still keeping the base\n * flexible.\n */\n\nmodule.exports = { // <--\n\n  /**\n   * If is a HTTP 1.0 request, remove chunk headers\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  removeChunked: function removeChunked(req, res, proxyRes) {\n    if (req.httpVersion === '1.0') {\n      delete proxyRes.headers['transfer-encoding'];\n    }\n  },\n\n  /**\n   * If is a HTTP 1.0 request, set the correct connection header\n   * or if connection header not present, then use `keep-alive`\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  setConnection: function setConnection(req, res, proxyRes) {\n    if (req.httpVersion === '1.0') {\n      proxyRes.headers.connection = req.headers.connection || 'close';\n    } else if (req.httpVersion !== '2.0' && !proxyRes.headers.connection) {\n      proxyRes.headers.connection = req.headers.connection || 'keep-alive';\n    }\n  },\n\n  setRedirectHostRewrite: function setRedirectHostRewrite(req, res, proxyRes, options) {\n    if ((options.hostRewrite || options.autoRewrite || options.protocolRewrite)\n        && proxyRes.headers['location']\n        && redirectRegex.test(proxyRes.statusCode)) {\n      var target = url.parse(options.target);\n      var u = url.parse(proxyRes.headers['location']);\n\n      // make sure the redirected host matches the target host before rewriting\n      if (target.host != u.host) {\n        return;\n      }\n\n      if (options.hostRewrite) {\n        u.host = options.hostRewrite;\n      } else if (options.autoRewrite) {\n        u.host = req.headers['host'];\n      }\n      if (options.protocolRewrite) {\n        u.protocol = options.protocolRewrite;\n      }\n\n      proxyRes.headers['location'] = u.format();\n    }\n  },\n  /**\n   * Copy headers from proxyResponse to response\n   * set each header in response object.\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   * @param {Object} Options options.cookieDomainRewrite: Config to rewrite cookie domain\n   *\n   * @api private\n   */\n  writeHeaders: function writeHeaders(req, res, proxyRes, options) {\n    var rewriteCookieDomainConfig = options.cookieDomainRewrite,\n        rewriteCookiePathConfig = options.cookiePathRewrite,\n        preserveHeaderKeyCase = options.preserveHeaderKeyCase,\n        rawHeaderKeyMap,\n        setHeader = function(key, header) {\n          if (header == undefined) return;\n          if (rewriteCookieDomainConfig && key.toLowerCase() === 'set-cookie') {\n            header = common.rewriteCookieProperty(header, rewriteCookieDomainConfig, 'domain');\n          }\n          if (rewriteCookiePathConfig && key.toLowerCase() === 'set-cookie') {\n            header = common.rewriteCookieProperty(header, rewriteCookiePathConfig, 'path');\n          }\n          res.setHeader(String(key).trim(), header);\n        };\n\n    if (typeof rewriteCookieDomainConfig === 'string') { //also test for ''\n      rewriteCookieDomainConfig = { '*': rewriteCookieDomainConfig };\n    }\n\n    if (typeof rewriteCookiePathConfig === 'string') { //also test for ''\n      rewriteCookiePathConfig = { '*': rewriteCookiePathConfig };\n    }\n\n    // message.rawHeaders is added in: v0.11.6\n    // https://nodejs.org/api/http.html#http_message_rawheaders\n    if (preserveHeaderKeyCase && proxyRes.rawHeaders != undefined) {\n      rawHeaderKeyMap = {};\n      for (var i = 0; i < proxyRes.rawHeaders.length; i += 2) {\n        var key = proxyRes.rawHeaders[i];\n        rawHeaderKeyMap[key.toLowerCase()] = key;\n      }\n    }\n\n    Object.keys(proxyRes.headers).forEach(function(key) {\n      var header = proxyRes.headers[key];\n      if (preserveHeaderKeyCase && rawHeaderKeyMap) {\n        key = rawHeaderKeyMap[key] || key;\n      }\n      setHeader(key, header);\n    });\n  },\n\n  /**\n   * Set the statusCode from the proxyResponse\n   *\n   * @param {ClientRequest} Req Request object\n   * @param {IncomingMessage} Res Response object\n   * @param {proxyResponse} Res Response object from the proxy request\n   *\n   * @api private\n   */\n  writeStatusCode: function writeStatusCode(req, res, proxyRes) {\n    // From Node.js docs: response.writeHead(statusCode[, statusMessage][, headers])\n    if(proxyRes.statusMessage) {\n      res.statusCode = proxyRes.statusCode;\n      res.statusMessage = proxyRes.statusMessage;\n    } else {\n      res.statusCode = proxyRes.statusCode;\n    }\n  }\n\n};\n"],"mappings":"AAAA,IAAIA,GAAG,GAAMC,OAAO,CAAC,KAAK,CAAC;EACvBC,MAAM,GAAGD,OAAO,CAAC,WAAW,CAAC;AAGjC,IAAIE,aAAa,GAAG,mBAAmB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEAC,MAAM,CAACC,OAAO,GAAG;EAAE;;EAEjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,aAAa,EAAE,SAASA,aAAaA,CAACC,GAAG,EAAEC,GAAG,EAAEC,QAAQ,EAAE;IACxD,IAAIF,GAAG,CAACG,WAAW,KAAK,KAAK,EAAE;MAC7B,OAAOD,QAAQ,CAACE,OAAO,CAAC,mBAAmB,CAAC;IAC9C;EACF,CAAC;EAED;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