@requestly/requestly-proxy 1.3.4 → 1.3.5
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.
|
@@ -8,6 +8,21 @@ declare function handleMixedResponse(ctx: any, destinationUrl: any): Promise<{
|
|
|
8
8
|
status_code: number;
|
|
9
9
|
body: any;
|
|
10
10
|
};
|
|
11
|
+
} | {
|
|
12
|
+
status: boolean;
|
|
13
|
+
response_data: {
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": any;
|
|
16
|
+
"Content-Length": number;
|
|
17
|
+
"Cache-Control": string;
|
|
18
|
+
} | {
|
|
19
|
+
"Cache-Control": string;
|
|
20
|
+
"Content-Type"?: undefined;
|
|
21
|
+
"Content-Length"?: undefined;
|
|
22
|
+
};
|
|
23
|
+
status_code: number;
|
|
24
|
+
body: string;
|
|
25
|
+
};
|
|
11
26
|
} | {
|
|
12
27
|
status: boolean;
|
|
13
28
|
response_data?: undefined;
|
|
@@ -30,6 +30,7 @@ const axios = require("axios");
|
|
|
30
30
|
const parser = require("ua-parser-js");
|
|
31
31
|
const fs_1 = __importDefault(require("fs"));
|
|
32
32
|
const Sentry = __importStar(require("@sentry/browser"));
|
|
33
|
+
const mime = require('mime-types');
|
|
33
34
|
const handleMixedResponse = async (ctx, destinationUrl) => {
|
|
34
35
|
var _a, _b, _c;
|
|
35
36
|
// Handling mixed response from safari
|
|
@@ -71,14 +72,22 @@ const handleMixedResponse = async (ctx, destinationUrl) => {
|
|
|
71
72
|
if (destinationUrl === null || destinationUrl === void 0 ? void 0 : destinationUrl.startsWith("file://")) {
|
|
72
73
|
const path = destinationUrl.slice(7);
|
|
73
74
|
try {
|
|
74
|
-
|
|
75
|
-
const
|
|
75
|
+
const buffers = fs_1.default.readFileSync(path);
|
|
76
|
+
const mimeType = mime.lookup(path);
|
|
77
|
+
const bodyContent = buffers.toString("utf-8"); // assuming utf-8 encoding
|
|
78
|
+
const headers = mimeType ? {
|
|
79
|
+
"Content-Type": mimeType,
|
|
80
|
+
"Content-Length": Buffer.byteLength(bodyContent),
|
|
81
|
+
"Cache-Control": "no-cache"
|
|
82
|
+
} : {
|
|
83
|
+
"Cache-Control": "no-cache"
|
|
84
|
+
};
|
|
76
85
|
return {
|
|
77
86
|
status: true,
|
|
78
87
|
response_data: {
|
|
79
|
-
headers
|
|
88
|
+
headers,
|
|
80
89
|
status_code: 200,
|
|
81
|
-
body:
|
|
90
|
+
body: buffers.toString("utf-8"), // assuming utf-8 encoding
|
|
82
91
|
},
|
|
83
92
|
};
|
|
84
93
|
}
|