[rm] removed request types, due to unsafe
This commit is contained in:
@@ -26,25 +26,11 @@
|
|||||||
<span class="text-neutral-200">{language.requestretrys}</span>
|
<span class="text-neutral-200">{language.requestretrys}</span>
|
||||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" type="number" min={0} max="20" bind:value={$DataBase.requestRetrys}>
|
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" type="number" min={0} max="20" bind:value={$DataBase.requestRetrys}>
|
||||||
|
|
||||||
<span class="text-neutral-200">Request Type</span>
|
<span class="text-neutral-200">Request Lib</span>
|
||||||
<select class="bg-transparent input-text text-gray-200 appearance-none text-sm mb-4" bind:value={$DataBase.requestmet}>
|
<select class="bg-transparent input-text text-gray-200 appearance-none text-sm" bind:value={$DataBase.requester}>
|
||||||
<option value="normal" class="bg-darkbg appearance-none">Normal</option>
|
<option value="new" class="bg-darkbg appearance-none">Reqwest</option>
|
||||||
<option value="proxy" class="bg-darkbg appearance-none">Proxy</option>
|
<option value="old" class="bg-darkbg appearance-none">Tauri</option>
|
||||||
<option value="plain" class="bg-darkbg appearance-none">Plain Fetch</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
{#if $DataBase.requestmet === 'proxy'}
|
|
||||||
<span class="text-neutral-200">Request Proxy URL</span>
|
|
||||||
<input class="text-neutral-200 mb-4 p-2 bg-transparent input-text focus:bg-selected text-sm" bind:value={$DataBase.requestproxy}>
|
|
||||||
{/if}
|
|
||||||
{#if isTauri && $DataBase.requestmet === 'normal'}
|
|
||||||
<span class="text-neutral-200">Request Lib</span>
|
|
||||||
<select class="bg-transparent input-text text-gray-200 appearance-none text-sm" bind:value={$DataBase.requester}>
|
|
||||||
<option value="new" class="bg-darkbg appearance-none">Reqwest</option>
|
|
||||||
<option value="old" class="bg-darkbg appearance-none">Tauri</option>
|
|
||||||
</select>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="flex items-center mt-4">
|
<div class="flex items-center mt-4">
|
||||||
<Check bind:check={$DataBase.useSayNothing} name={language.sayNothing}/>
|
<Check bind:check={$DataBase.useSayNothing} name={language.sayNothing}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
|||||||
try {
|
try {
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
const method = arg.method ?? "POST"
|
const method = arg.method ?? "POST"
|
||||||
|
db.requestmet = "normal"
|
||||||
|
|
||||||
function addFetchLog(response:any, success:boolean){
|
function addFetchLog(response:any, success:boolean){
|
||||||
try{
|
try{
|
||||||
@@ -410,7 +411,7 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
|||||||
const urlHost = (new URL(url)).hostname
|
const urlHost = (new URL(url)).hostname
|
||||||
let forcePlainFetch = knownHostes.includes(urlHost) && (!isTauri)
|
let forcePlainFetch = knownHostes.includes(urlHost) && (!isTauri)
|
||||||
|
|
||||||
if(db.requestmet === 'plain' || forcePlainFetch){
|
if(forcePlainFetch){
|
||||||
try {
|
try {
|
||||||
let headers = arg.headers ?? {}
|
let headers = arg.headers ?? {}
|
||||||
if(!headers["Content-Type"]){
|
if(!headers["Content-Type"]){
|
||||||
@@ -451,48 +452,6 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(db.requestmet === 'proxy'){
|
|
||||||
try {
|
|
||||||
let headers = arg.headers ?? {}
|
|
||||||
if(!headers["Content-Type"]){
|
|
||||||
headers["Content-Type"] = `application/json`
|
|
||||||
}
|
|
||||||
const furl = new URL(db.requestproxy)
|
|
||||||
furl.pathname = url
|
|
||||||
|
|
||||||
const da = await fetch(furl, {
|
|
||||||
body: JSON.stringify(arg.body),
|
|
||||||
headers: arg.headers,
|
|
||||||
method: method,
|
|
||||||
signal: arg.abortSignal
|
|
||||||
})
|
|
||||||
|
|
||||||
if(arg.rawResponse){
|
|
||||||
addFetchLog("Uint8Array Response", da.ok && da.status >= 200 && da.status < 300)
|
|
||||||
return {
|
|
||||||
ok: da.ok && da.status >= 200 && da.status < 300,
|
|
||||||
data: new Uint8Array(await da.arrayBuffer()),
|
|
||||||
headers: Object.fromEntries(da.headers)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
const dat = await da.json()
|
|
||||||
addFetchLog(dat, da.ok && da.status >= 200 && da.status < 300)
|
|
||||||
return {
|
|
||||||
ok: da.ok && da.status >= 200 && da.status < 300,
|
|
||||||
data: dat,
|
|
||||||
headers: Object.fromEntries(da.headers)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
return {
|
|
||||||
ok: false,
|
|
||||||
data: `${error}`,
|
|
||||||
headers: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isTauri){
|
if(isTauri){
|
||||||
if(db.requester === 'new'){
|
if(db.requester === 'new'){
|
||||||
try {
|
try {
|
||||||
@@ -609,8 +568,8 @@ export async function globalFetch(url:string, arg:{body?:any,headers?:{[key:stri
|
|||||||
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
"risu-header": encodeURIComponent(JSON.stringify(arg.headers)),
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
method: method
|
method: method,
|
||||||
,signal: arg.abortSignal
|
signal: arg.abortSignal
|
||||||
})
|
})
|
||||||
|
|
||||||
addFetchLog("Uint8Array Response", da.ok && da.status >= 200 && da.status < 300)
|
addFetchLog("Uint8Array Response", da.ok && da.status >= 200 && da.status < 300)
|
||||||
|
|||||||
Reference in New Issue
Block a user