@requestly/requestly-proxy 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,14 +40,13 @@ const parser = require("ua-parser-js");
40
40
  const Sentry = __importStar(require("@sentry/browser"));
41
41
  const https_1 = __importDefault(require("https"));
42
42
  const http_1 = __importDefault(require("http"));
43
- const willCreateMixedResponse = (ctx, destinationUrl) => {
44
- var _a, _b, _c, _d;
43
+ const willCreateMixedResponseThatCanBeHandled = (ctx, destinationUrl) => {
44
+ var _a, _b, _c;
45
45
  let user_agent_str = null;
46
46
  user_agent_str = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.clientToProxyRequest) === null || _a === void 0 ? void 0 : _a.headers["user-agent"];
47
- console.log("handling mixed response. i got headers", (_b = ctx === null || ctx === void 0 ? void 0 : ctx.clientToProxyRequest) === null || _b === void 0 ? void 0 : _b.headers);
48
- const user_agent = (_d = (_c = parser(user_agent_str)) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.name;
47
+ const user_agent = (_c = (_b = parser(user_agent_str)) === null || _b === void 0 ? void 0 : _b.browser) === null || _c === void 0 ? void 0 : _c.name;
49
48
  const LOCAL_DOMAINS = ["localhost", "127.0.0.1"];
50
- return ctx.isSSL && destinationUrl.includes("http") && (user_agent === "Safari" ||
49
+ return ctx.isSSL && destinationUrl.includes("http:") && (user_agent === "Safari" ||
51
50
  !LOCAL_DOMAINS.some((domain) => destinationUrl.includes(domain)));
52
51
  };
53
52
  const canPreserveCookie = (ctx, destinationUrl) => {
@@ -82,7 +81,7 @@ const canPreserveCookie = (ctx, destinationUrl) => {
82
81
  };
83
82
  const shouldMakeExternalRequest = (ctx, action) => {
84
83
  return ((action.preserveCookie && canPreserveCookie(ctx, action.url)) ||
85
- willCreateMixedResponse(ctx, action.url));
84
+ willCreateMixedResponseThatCanBeHandled(ctx, action.url));
86
85
  };
87
86
  exports.shouldMakeExternalRequest = shouldMakeExternalRequest;
88
87
  function makeRequest(requestOptions) {
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.MIDDLEWARE_TYPE = void 0;
16
16
  // Move Proxy code to this package
17
17
  var net = require("net");
18
+ const http_1 = __importDefault(require("http"));
18
19
  const proxy_1 = __importDefault(require("../../lib/proxy"));
19
20
  const proxy_ctx_helper_1 = require("./helpers/proxy_ctx_helper");
20
21
  const rules_middleware_1 = __importDefault(require("./middlewares/rules_middleware"));
@@ -149,7 +150,8 @@ class ProxyMiddlewareManager {
149
150
  // Remove some conflicting headers like content-length, if any
150
151
  delete (0, proxy_ctx_helper_1.getResponseHeaders)(ctx)["content-length"];
151
152
  }
152
- ctx.proxyToClientResponse.writeHead(ctx.rq_response_status_code || (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx), (0, proxy_ctx_helper_1.getResponseHeaders)(ctx));
153
+ const statusCode = ctx.rq_response_status_code || (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx);
154
+ ctx.proxyToClientResponse.writeHead(statusCode, http_1.default.STATUS_CODES[statusCode], (0, proxy_ctx_helper_1.getResponseHeaders)(ctx));
153
155
  ctx.proxyToClientResponse.write(ctx.rq_response_body);
154
156
  ctx.rq.set_final_response(Object.assign(Object.assign({}, (0, proxy_ctx_helper_1.get_response_options)(ctx)), { status_code: ctx.rq_response_status_code || (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx), body: ctx.rq_response_body }));
155
157
  logger_middleware.send_network_log(ctx, rules_middleware.action_result_objs, requestly_core_1.CONSTANTS.REQUEST_STATE.COMPLETE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestly/requestly-proxy",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Proxy that gives superpowers to all the Requestly clients",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {