mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
fix: requests suck
This commit is contained in:
parent
7b0769ced4
commit
8b8c9b4741
4 changed files with 21 additions and 17 deletions
|
@ -44,7 +44,7 @@
|
||||||
"@types/eslint": "^9.6.1",
|
"@types/eslint": "^9.6.1",
|
||||||
"@types/estree": "^1.0.6",
|
"@types/estree": "^1.0.6",
|
||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.9.0",
|
||||||
"@types/serviceworker": "^0.0.102",
|
"@types/serviceworker": "^0.0.103",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
||||||
"@typescript-eslint/parser": "^8.13.0",
|
"@typescript-eslint/parser": "^8.13.0",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
"wisp-server-node": "^1.1.7"
|
"wisp-server-node": "^1.1.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mercuryworkshop/bare-mux": "^2.1.6",
|
"@mercuryworkshop/bare-mux": "^2.1.7",
|
||||||
"dom-serializer": "^2.0.0",
|
"dom-serializer": "^2.0.0",
|
||||||
"domhandler": "^5.0.3",
|
"domhandler": "^5.0.3",
|
||||||
"domutils": "^3.1.0",
|
"domutils": "^3.1.0",
|
||||||
|
|
20
pnpm-lock.yaml
generated
20
pnpm-lock.yaml
generated
|
@ -9,8 +9,8 @@ importers:
|
||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@mercuryworkshop/bare-mux':
|
'@mercuryworkshop/bare-mux':
|
||||||
specifier: ^2.1.6
|
specifier: ^2.1.7
|
||||||
version: 2.1.6
|
version: 2.1.7
|
||||||
dom-serializer:
|
dom-serializer:
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
version: 2.0.0
|
version: 2.0.0
|
||||||
|
@ -76,8 +76,8 @@ importers:
|
||||||
specifier: ^22.9.0
|
specifier: ^22.9.0
|
||||||
version: 22.9.0
|
version: 22.9.0
|
||||||
'@types/serviceworker':
|
'@types/serviceworker':
|
||||||
specifier: ^0.0.102
|
specifier: ^0.0.103
|
||||||
version: 0.0.102
|
version: 0.0.103
|
||||||
'@typescript-eslint/eslint-plugin':
|
'@typescript-eslint/eslint-plugin':
|
||||||
specifier: ^8.13.0
|
specifier: ^8.13.0
|
||||||
version: 8.13.0(@typescript-eslint/parser@8.13.0(eslint@9.14.0)(typescript@5.6.3))(eslint@9.14.0)(typescript@5.6.3)
|
version: 8.13.0(@typescript-eslint/parser@8.13.0(eslint@9.14.0)(typescript@5.6.3))(eslint@9.14.0)(typescript@5.6.3)
|
||||||
|
@ -276,8 +276,8 @@ packages:
|
||||||
'@mercuryworkshop/bare-as-module3@2.2.5':
|
'@mercuryworkshop/bare-as-module3@2.2.5':
|
||||||
resolution: {integrity: sha512-KWlMVJoJ3h1ya3chlpzIyQrt01rSU21AU1vBsGUrhZngCVTs9SIMGMqBx61TM0gWtEUogYFfU5U0UF1XCYeUHQ==}
|
resolution: {integrity: sha512-KWlMVJoJ3h1ya3chlpzIyQrt01rSU21AU1vBsGUrhZngCVTs9SIMGMqBx61TM0gWtEUogYFfU5U0UF1XCYeUHQ==}
|
||||||
|
|
||||||
'@mercuryworkshop/bare-mux@2.1.6':
|
'@mercuryworkshop/bare-mux@2.1.7':
|
||||||
resolution: {integrity: sha512-SMpPwHrRjeqBfuh5N9SKD2G7uzfQiOeiENcYjb0BYTpOEOFvoPDhjSppSZMSkN1maJJ1NNtCRv9Qb+uCeJWwgw==}
|
resolution: {integrity: sha512-BUamyc7jsIFbWQVVWjVjaD+Wot77EPwolkrbP3UuIs6QeHR1RY52+IR2fq3GkRAbOOrAZNT7EgZSsupkh1NowQ==}
|
||||||
|
|
||||||
'@mercuryworkshop/epoxy-tls@2.1.15-1':
|
'@mercuryworkshop/epoxy-tls@2.1.15-1':
|
||||||
resolution: {integrity: sha512-XcagLkLBIi+rjgr4WcI37m5EJ+FZbURDusnBvphtpQbcSVs5D/FwzUgVBLw92U6+Uragt0HC9POZ2UWmYkt0aA==}
|
resolution: {integrity: sha512-XcagLkLBIi+rjgr4WcI37m5EJ+FZbURDusnBvphtpQbcSVs5D/FwzUgVBLw92U6+Uragt0HC9POZ2UWmYkt0aA==}
|
||||||
|
@ -514,8 +514,8 @@ packages:
|
||||||
'@types/serve-static@1.15.7':
|
'@types/serve-static@1.15.7':
|
||||||
resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==}
|
resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==}
|
||||||
|
|
||||||
'@types/serviceworker@0.0.102':
|
'@types/serviceworker@0.0.103':
|
||||||
resolution: {integrity: sha512-RAjnnU9rNWwlO5cyrifmShjudE4yQtFpFhwA7SOf2t0pk0DeRh1aBROJd4zk4er/WOU0o0eTRTi/CBuxuO27Gg==}
|
resolution: {integrity: sha512-EOiLGcQeb/r/POn4Nlbz8XVApoYPtLNACbaqpge6sSuydA8nj/5S6oqISFRwQ33n8pIOIrWFm17S9cnmrO2QAw==}
|
||||||
|
|
||||||
'@types/sockjs@0.3.36':
|
'@types/sockjs@0.3.36':
|
||||||
resolution: {integrity: sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q==}
|
resolution: {integrity: sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q==}
|
||||||
|
@ -2647,7 +2647,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript: 5.6.3
|
typescript: 5.6.3
|
||||||
|
|
||||||
'@mercuryworkshop/bare-mux@2.1.6': {}
|
'@mercuryworkshop/bare-mux@2.1.7': {}
|
||||||
|
|
||||||
'@mercuryworkshop/epoxy-tls@2.1.15-1': {}
|
'@mercuryworkshop/epoxy-tls@2.1.15-1': {}
|
||||||
|
|
||||||
|
@ -3019,7 +3019,7 @@ snapshots:
|
||||||
'@types/node': 22.9.0
|
'@types/node': 22.9.0
|
||||||
'@types/send': 0.17.4
|
'@types/send': 0.17.4
|
||||||
|
|
||||||
'@types/serviceworker@0.0.102': {}
|
'@types/serviceworker@0.0.103': {}
|
||||||
|
|
||||||
'@types/sockjs@0.3.36':
|
'@types/sockjs@0.3.36':
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -160,7 +160,11 @@ export async function handleFetch(
|
||||||
method: ev.method,
|
method: ev.method,
|
||||||
body: ev.body,
|
body: ev.body,
|
||||||
headers: ev.requestHeaders,
|
headers: ev.requestHeaders,
|
||||||
//@ts-expect-error no types
|
credentials: "omit",
|
||||||
|
mode: request.mode === "cors" ? request.mode : "same-origin",
|
||||||
|
cache: request.cache,
|
||||||
|
redirect: "manual",
|
||||||
|
//@ts-ignore why the fuck is this not typed mircosoft
|
||||||
duplex: "half",
|
duplex: "half",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -304,7 +308,7 @@ async function handleResponse(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rewriteBody(
|
async function rewriteBody(
|
||||||
response: Response,
|
response: BareResponseFetch,
|
||||||
meta: URLMeta,
|
meta: URLMeta,
|
||||||
destination: RequestDestination,
|
destination: RequestDestination,
|
||||||
workertype: string,
|
workertype: string,
|
||||||
|
@ -319,7 +323,7 @@ async function rewriteBody(
|
||||||
return response.body;
|
return response.body;
|
||||||
}
|
}
|
||||||
case "script":
|
case "script":
|
||||||
return rewriteJs(await response.arrayBuffer(), response.url, meta);
|
return rewriteJs(await response.arrayBuffer(), response.finalURL, meta);
|
||||||
case "style":
|
case "style":
|
||||||
return rewriteCss(await response.text(), meta);
|
return rewriteCss(await response.text(), meta);
|
||||||
case "sharedworker":
|
case "sharedworker":
|
||||||
|
@ -327,7 +331,7 @@ async function rewriteBody(
|
||||||
return rewriteWorkers(
|
return rewriteWorkers(
|
||||||
await response.arrayBuffer(),
|
await response.arrayBuffer(),
|
||||||
workertype,
|
workertype,
|
||||||
response.url,
|
response.finalURL,
|
||||||
meta
|
meta
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -62,6 +62,6 @@ scramjet.addEventListener("request", (e) => {
|
||||||
}
|
}
|
||||||
if (playgroundData) {
|
if (playgroundData) {
|
||||||
e.response.rawHeaders = headers;
|
e.response.rawHeaders = headers;
|
||||||
e.response.finalURL = e.url;
|
e.response.finalURL = e.url.toString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue