runlocal 0.3.0 → 0.3.1
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.
- package/index.js +7 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -63,7 +63,7 @@ function connect() {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (event === "http_request") {
|
|
66
|
-
handleRequest(ws, topic, payload);
|
|
66
|
+
handleRequest(ws, joinRef, topic, payload);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -90,7 +90,7 @@ function connect() {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
function handleRequest(ws, topic, payload) {
|
|
93
|
+
function handleRequest(ws, joinRef, topic, payload) {
|
|
94
94
|
const { request_id, method, path, query_string, headers, body } = payload;
|
|
95
95
|
const fullPath = query_string ? `${path}?${query_string}` : path;
|
|
96
96
|
|
|
@@ -102,8 +102,9 @@ function handleRequest(ws, topic, payload) {
|
|
|
102
102
|
const reqHeaders = {};
|
|
103
103
|
if (headers) {
|
|
104
104
|
for (const [k, v] of headers) {
|
|
105
|
-
// Skip host header
|
|
106
|
-
|
|
105
|
+
// Skip host header (proxying to localhost) and accept-encoding
|
|
106
|
+
// (compressed responses corrupt during string conversion)
|
|
107
|
+
if (k.toLowerCase() !== "host" && k.toLowerCase() !== "accept-encoding") {
|
|
107
108
|
reqHeaders[k] = v;
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -141,7 +142,7 @@ function handleRequest(ws, topic, payload) {
|
|
|
141
142
|
|
|
142
143
|
ws.send(
|
|
143
144
|
JSON.stringify([
|
|
144
|
-
|
|
145
|
+
joinRef,
|
|
145
146
|
nextRef(),
|
|
146
147
|
topic,
|
|
147
148
|
"http_response",
|
|
@@ -162,7 +163,7 @@ function handleRequest(ws, topic, payload) {
|
|
|
162
163
|
);
|
|
163
164
|
ws.send(
|
|
164
165
|
JSON.stringify([
|
|
165
|
-
|
|
166
|
+
joinRef,
|
|
166
167
|
nextRef(),
|
|
167
168
|
topic,
|
|
168
169
|
"http_response",
|