mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-06 10:59:04 +08:00
fix
This commit is contained in:
parent
0e5e21dc4e
commit
8661d09d57
@ -26,4 +26,32 @@ export async function HttpGetWithCookies(url: string): Promise<Map<string, strin
|
|||||||
req.end()
|
req.end()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
export async function HttpPostCookies(url: string): Promise<Map<string, string>> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let result: Map<string, string> = new Map<string, string>();
|
||||||
|
const req = https.get(url, (res: any) => {
|
||||||
|
res.on('data', (data: any) => {
|
||||||
|
});
|
||||||
|
res.on('end', () => {
|
||||||
|
try {
|
||||||
|
const responseCookies = res.headers['set-cookie'];
|
||||||
|
for (const line of responseCookies) {
|
||||||
|
const parts = line.split(';');
|
||||||
|
const [key, value] = parts[0].split('=');
|
||||||
|
result.set(key, value);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (error: any) => {
|
||||||
|
resolve(result);
|
||||||
|
// console.log(error)
|
||||||
|
})
|
||||||
|
req.end()
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user