This commit is contained in:
手瓜一十雪
2024-04-28 11:19:09 +08:00
parent 0e5e21dc4e
commit 8661d09d57

View File

@@ -26,4 +26,32 @@ export async function HttpGetWithCookies(url: string): Promise<Map<string, strin
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()
})
}