http_utils.d.ts 1.1 KB

123456789101112131415161718192021222324252627
  1. /// <reference types="request" />
  2. import { OptionsWithUrl } from 'request';
  3. export interface RequestOptionsValue {
  4. proxy?: string;
  5. ignoreSSL?: boolean;
  6. }
  7. export declare class HttpUtils {
  8. static requestOpts: RequestOptionsValue;
  9. static assignOptions(options: RequestOptionsValue): void;
  10. static initOptions(url: string, timeout?: number): OptionsWithUrl;
  11. static optionsSSL(options: OptionsWithUrl, opt_ignoreSSL: boolean): OptionsWithUrl;
  12. static optionsProxy(options: OptionsWithUrl, requestUrl: string, opt_proxy: string): OptionsWithUrl;
  13. static optionsHeader(options: OptionsWithUrl, key: string, value: string): OptionsWithUrl;
  14. /**
  15. * Resolves proxy based on values set
  16. * @param fileUrl The url to download the file.
  17. * @param opt_proxy The proxy to connect to to download files.
  18. * @return Either undefined or the proxy.
  19. */
  20. static resolveProxy(fileUrl: string, opt_proxy?: string): string;
  21. }
  22. /**
  23. * Request the body from the url.
  24. * @param requestUrl The request url.
  25. * @returns A promise string of the response body.
  26. */
  27. export declare function requestBody(requestUrl: string): Promise<string>;