mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
add xmlhttprequest support
This commit is contained in:
parent
d4295e902d
commit
3b27792325
2 changed files with 22 additions and 3 deletions
|
@ -1,12 +1,13 @@
|
||||||
import "./location";
|
import "./location";
|
||||||
|
import "./trustedTypes.ts";
|
||||||
|
import "./eval.ts";
|
||||||
import "./storage";
|
import "./storage";
|
||||||
import "./element.ts";
|
import "./element.ts";
|
||||||
import "./eval.ts";
|
|
||||||
import "./fetch.ts";
|
import "./fetch.ts";
|
||||||
import "./trustedTypes.ts";
|
import "./xmlhttprequest.ts";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__location: Location;
|
__location: Location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/client/xmlhttprequest.ts
Normal file
18
src/client/xmlhttprequest.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
XMLHttpRequest.prototype.open = new Proxy(XMLHttpRequest.prototype.open, {
|
||||||
|
apply(target, thisArg, argArray) {
|
||||||
|
if (argArray[1]) argArray[1] = self.__scramjet$bundle.rewriters.url.encodeUrl(argArray[1]);
|
||||||
|
|
||||||
|
return Reflect.apply(target, thisArg, argArray);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
XMLHttpRequest.prototype.setRequestHeader = new Proxy(XMLHttpRequest.prototype.setRequestHeader, {
|
||||||
|
apply(target, thisArg, argArray) {
|
||||||
|
let headerObject = Object.fromEntries(argArray);
|
||||||
|
headerObject = self.__scramjet$bundle.rewriters.rewriteHeaders(headerObject);
|
||||||
|
|
||||||
|
argArray = Object.entries(headerObject);
|
||||||
|
|
||||||
|
return Reflect.apply(target, thisArg, argArray);
|
||||||
|
},
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue