Fully https working

This commit is contained in:
killer069
2021-09-13 10:23:18 +05:30
parent ad22f873e5
commit 998f16d1ac
4 changed files with 26 additions and 30 deletions

View File

@@ -14,7 +14,8 @@ async function https_getter(req_url : string, options : RequestOpts = {}): Promi
let req_options : RequestOptions = {
host : s.hostname,
path : s.pathname + s.search,
headers : (options.headers) ? options.headers : {}
headers : (options.headers) ? options.headers : {},
method : options.method
}
let req = https.request(req_options, (response) => {
@@ -48,9 +49,6 @@ export async function request_stream(url : string, options? : RequestOpts): Prom
if(Number(res.statusCode) >= 300 && Number(res.statusCode) < 400){
res = await https_getter(res.headers.location as string, options)
}
else if(Number(res.statusCode) > 400){
reject(`Got ${res.statusCode} from the request`)
}
resolve(res)
})
}