svelte-adapter-uws 0.4.13 → 0.4.14
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 +20 -16
- package/package.json +1 -1
- package/testing.js +13 -9
package/files/handler.js
CHANGED
|
@@ -1653,7 +1653,9 @@ if (WS_ENABLED) {
|
|
|
1653
1653
|
// no cookie parsing). Inject remoteAddress so plugins/ratelimit can
|
|
1654
1654
|
// key on the real client IP via ws.getUserData().remoteAddress.
|
|
1655
1655
|
if (!wsModule.upgrade) {
|
|
1656
|
-
res.
|
|
1656
|
+
res.cork(() => {
|
|
1657
|
+
res.upgrade({ remoteAddress: clientIp }, secKey, secProtocol, secExtensions, context);
|
|
1658
|
+
});
|
|
1657
1659
|
return;
|
|
1658
1660
|
}
|
|
1659
1661
|
|
|
@@ -1723,23 +1725,25 @@ if (WS_ENABLED) {
|
|
|
1723
1725
|
}
|
|
1724
1726
|
const ud = userData || {};
|
|
1725
1727
|
if (!ud.remoteAddress) ud.remoteAddress = clientIp;
|
|
1726
|
-
if (responseHeaders)
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1728
|
+
if (responseHeaders) maybeWarnSetCookieOnUpgrade(responseHeaders);
|
|
1729
|
+
res.cork(() => {
|
|
1730
|
+
if (responseHeaders) {
|
|
1731
|
+
for (const [hk, hv] of Object.entries(responseHeaders)) {
|
|
1732
|
+
if (Array.isArray(hv)) {
|
|
1733
|
+
for (const v of hv) res.writeHeader(hk, v);
|
|
1734
|
+
} else {
|
|
1735
|
+
res.writeHeader(hk, hv);
|
|
1736
|
+
}
|
|
1733
1737
|
}
|
|
1734
1738
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
);
|
|
1739
|
+
res.upgrade(
|
|
1740
|
+
ud,
|
|
1741
|
+
secKey,
|
|
1742
|
+
secProtocol,
|
|
1743
|
+
secExtensions,
|
|
1744
|
+
context
|
|
1745
|
+
);
|
|
1746
|
+
});
|
|
1743
1747
|
})
|
|
1744
1748
|
.catch((err) => {
|
|
1745
1749
|
clearTimeout(timer);
|
package/package.json
CHANGED
package/testing.js
CHANGED
|
@@ -115,7 +115,9 @@ export async function createTestServer(options = {}) {
|
|
|
115
115
|
const rawIp = new TextDecoder().decode(res.getRemoteAddressAsText());
|
|
116
116
|
|
|
117
117
|
if (!handler.upgrade) {
|
|
118
|
-
res.
|
|
118
|
+
res.cork(() => {
|
|
119
|
+
res.upgrade({ remoteAddress: rawIp }, secKey, secProtocol, secExtensions, context);
|
|
120
|
+
});
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
123
|
|
|
@@ -143,16 +145,18 @@ export async function createTestServer(options = {}) {
|
|
|
143
145
|
userData = result || {};
|
|
144
146
|
}
|
|
145
147
|
if (!userData.remoteAddress) userData.remoteAddress = rawIp;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
res.cork(() => {
|
|
149
|
+
if (responseHeaders) {
|
|
150
|
+
for (const [hk, hv] of Object.entries(responseHeaders)) {
|
|
151
|
+
if (Array.isArray(hv)) {
|
|
152
|
+
for (const v of hv) res.writeHeader(hk, v);
|
|
153
|
+
} else {
|
|
154
|
+
res.writeHeader(hk, hv);
|
|
155
|
+
}
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
res.upgrade(userData, secKey, secProtocol, secExtensions, context);
|
|
159
|
+
});
|
|
156
160
|
})
|
|
157
161
|
.catch((err) => {
|
|
158
162
|
if (!aborted) {
|