mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-31 14:58:05 +00:00
search validation added
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Response } from "./classes";
|
||||
|
||||
import { Response } from './classes';
|
||||
|
||||
export type Proxy = ProxyOpts | string;
|
||||
|
||||
@@ -16,38 +15,38 @@ interface RequestOptions {
|
||||
body?: string;
|
||||
method: 'GET' | 'POST';
|
||||
proxies?: Proxy[];
|
||||
cookies? : boolean
|
||||
headers? : Object;
|
||||
timeout? : number
|
||||
cookies?: boolean;
|
||||
headers?: Object;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface StreamGetterOptions{
|
||||
interface StreamGetterOptions {
|
||||
method: 'GET' | 'POST';
|
||||
cookies? : boolean
|
||||
headers : Object;
|
||||
cookies?: boolean;
|
||||
headers: Object;
|
||||
}
|
||||
|
||||
export function request_stream(req_url : string, options : RequestOptions = {method : "GET"}): Promise<Response>{
|
||||
return new Promise(async(resolve, reject) => {
|
||||
let res = new Response(req_url, options)
|
||||
await res.stream()
|
||||
export function request_stream(req_url: string, options: RequestOptions = { method: 'GET' }): Promise<Response> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let res = new Response(req_url, options);
|
||||
await res.stream();
|
||||
if (res.statusCode >= 300 && res.statusCode < 400) {
|
||||
res = await request_stream((res.headers as any).location, options);
|
||||
await res.stream()
|
||||
await res.stream();
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
resolve(res);
|
||||
});
|
||||
}
|
||||
|
||||
export function request(req_url : string, options : RequestOptions = {method : "GET"}): Promise<Response>{
|
||||
return new Promise(async(resolve, reject) => {
|
||||
let res = new Response(req_url, options)
|
||||
await res.fetch()
|
||||
export function request(req_url: string, options: RequestOptions = { method: 'GET' }): Promise<Response> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let res = new Response(req_url, options);
|
||||
await res.fetch();
|
||||
if (Number(res.statusCode) >= 300 && Number(res.statusCode) < 400) {
|
||||
res = await request((res.headers as any).location, options);
|
||||
} else if (Number(res.statusCode) > 400) {
|
||||
reject(new Error(`Got ${res.statusCode} from the request`));
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
resolve(res);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user