svelte-adapter-uws 0.4.10 → 0.4.11
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/files/handler.js +15 -19
- package/package.json +1 -1
- package/testing.js +9 -13
package/files/handler.js
CHANGED
|
@@ -1511,9 +1511,7 @@ if (WS_ENABLED) {
|
|
|
1511
1511
|
// no cookie parsing). Inject remoteAddress so plugins/ratelimit can
|
|
1512
1512
|
// key on the real client IP via ws.getUserData().remoteAddress.
|
|
1513
1513
|
if (!wsModule.upgrade) {
|
|
1514
|
-
res.
|
|
1515
|
-
res.upgrade({ remoteAddress: clientIp }, secKey, secProtocol, secExtensions, context);
|
|
1516
|
-
});
|
|
1514
|
+
res.upgrade({ remoteAddress: clientIp }, secKey, secProtocol, secExtensions, context);
|
|
1517
1515
|
return;
|
|
1518
1516
|
}
|
|
1519
1517
|
|
|
@@ -1583,24 +1581,22 @@ if (WS_ENABLED) {
|
|
|
1583
1581
|
}
|
|
1584
1582
|
const ud = userData || {};
|
|
1585
1583
|
if (!ud.remoteAddress) ud.remoteAddress = clientIp;
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
res.writeHeader(hk, hv);
|
|
1593
|
-
}
|
|
1584
|
+
if (responseHeaders) {
|
|
1585
|
+
for (const [hk, hv] of Object.entries(responseHeaders)) {
|
|
1586
|
+
if (Array.isArray(hv)) {
|
|
1587
|
+
for (const v of hv) res.writeHeader(hk, v);
|
|
1588
|
+
} else {
|
|
1589
|
+
res.writeHeader(hk, hv);
|
|
1594
1590
|
}
|
|
1595
1591
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1592
|
+
}
|
|
1593
|
+
res.upgrade(
|
|
1594
|
+
ud,
|
|
1595
|
+
secKey,
|
|
1596
|
+
secProtocol,
|
|
1597
|
+
secExtensions,
|
|
1598
|
+
context
|
|
1599
|
+
);
|
|
1604
1600
|
})
|
|
1605
1601
|
.catch((err) => {
|
|
1606
1602
|
clearTimeout(timer);
|
package/package.json
CHANGED
package/testing.js
CHANGED
|
@@ -115,9 +115,7 @@ export async function createTestServer(options = {}) {
|
|
|
115
115
|
const rawIp = new TextDecoder().decode(res.getRemoteAddressAsText());
|
|
116
116
|
|
|
117
117
|
if (!handler.upgrade) {
|
|
118
|
-
res.
|
|
119
|
-
res.upgrade({ remoteAddress: rawIp }, secKey, secProtocol, secExtensions, context);
|
|
120
|
-
});
|
|
118
|
+
res.upgrade({ remoteAddress: rawIp }, secKey, secProtocol, secExtensions, context);
|
|
121
119
|
return;
|
|
122
120
|
}
|
|
123
121
|
|
|
@@ -145,18 +143,16 @@ export async function createTestServer(options = {}) {
|
|
|
145
143
|
userData = result || {};
|
|
146
144
|
}
|
|
147
145
|
if (!userData.remoteAddress) userData.remoteAddress = rawIp;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
res.writeHeader(hk, hv);
|
|
155
|
-
}
|
|
146
|
+
if (responseHeaders) {
|
|
147
|
+
for (const [hk, hv] of Object.entries(responseHeaders)) {
|
|
148
|
+
if (Array.isArray(hv)) {
|
|
149
|
+
for (const v of hv) res.writeHeader(hk, v);
|
|
150
|
+
} else {
|
|
151
|
+
res.writeHeader(hk, hv);
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
}
|
|
155
|
+
res.upgrade(userData, secKey, secProtocol, secExtensions, context);
|
|
160
156
|
})
|
|
161
157
|
.catch((err) => {
|
|
162
158
|
if (!aborted) {
|