@requestly/requestly-proxy 1.1.21 → 1.1.22
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.
|
@@ -33,6 +33,19 @@ const bodyParser = (contentTypeHeader, buffer) => {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
return str_buffer;
|
|
36
|
+
/*
|
|
37
|
+
FOLLOWING IS HOW API CLIENT PARSES THE BODY
|
|
38
|
+
much simpler than above, but requires thorough testing
|
|
39
|
+
*/
|
|
40
|
+
// // todo: add support for other content types
|
|
41
|
+
// let parsedResponse;
|
|
42
|
+
// if (contentTypeHeader?.includes("image/")) {
|
|
43
|
+
// const raw = Buffer.from(buffer).toString("base64");
|
|
44
|
+
// parsedResponse = `data:${contentTypeHeader};base64,${raw}`;
|
|
45
|
+
// } else {
|
|
46
|
+
// parsedResponse = new TextDecoder().decode(buffer);
|
|
47
|
+
// }
|
|
48
|
+
// return parsedResponse;
|
|
36
49
|
};
|
|
37
50
|
exports.bodyParser = bodyParser;
|
|
38
51
|
const getContentType = (contentTypeHeader) => {
|
|
@@ -164,6 +164,10 @@ class ProxyMiddlewareManager {
|
|
|
164
164
|
ctx.rq_response_body = body;
|
|
165
165
|
ctx.rq_parsed_response_body = parsedBody;
|
|
166
166
|
ctx.rq_response_status_code = (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx);
|
|
167
|
+
if (constants_1.RQ_INTERCEPTED_CONTENT_TYPES.includes(contentType) && parsedBody) {
|
|
168
|
+
ctx.rq_response_body = parsedBody;
|
|
169
|
+
ctx.rq.set_original_response({ body: parsedBody });
|
|
170
|
+
}
|
|
167
171
|
const { action_result_objs, continue_request } = yield rules_middleware.on_response_end(ctx);
|
|
168
172
|
const statusCode = ctx.rq_response_status_code || (0, proxy_ctx_helper_1.getResponseStatusCode)(ctx);
|
|
169
173
|
ctx.proxyToClientResponse.writeHead(statusCode, http_1.default.STATUS_CODES[statusCode], (0, proxy_ctx_helper_1.getResponseHeaders)(ctx));
|