UNPKG

@klippa/nativescript-http

Version:

The best way to do HTTP requests in NativeScript, a drop-in replacement for the core HTTP with important improvements and additions like proper connection pooling, form data support and certificate pinning

33 lines (32 loc) 1.72 kB
import { ImageSource, HttpRequestOptions, HttpResponse, Headers } from "@nativescript/core"; import { ImageParseMethod } from "./http.common"; export { HTTPFormData, HTTPFormDataEntry, ImageParseMethod } from "./http.common"; export declare enum HttpResponseEncoding { UTF8 = 0, GBK = 1 } export declare const USER_AGENT_HEADER = "User-Agent"; export declare const USER_AGENT: string; export declare function request(options: HttpRequestOptions): Promise<HttpResponse>; export declare function getString(arg: any): Promise<string>; export declare function getJSON<T>(arg: any): Promise<T>; export declare function getImage(arg: any): Promise<ImageSource>; export declare function getFile(arg: any, destinationFilePath?: string): Promise<any>; export declare function getBinary(arg: any): Promise<ArrayBuffer>; export declare function addHeader(headers: Headers, key: string, value: string): void; export declare function setImageParseMethod(imageParseMethod: ImageParseMethod): void; export declare function setConcurrencyLimits(maxRequests: number, maxRequestsPerHost: number): void; export declare function clearCookies(): void; export declare function setUserAgent(userAgent?: string): void; export declare function certificatePinningAdd(pattern: string, hashes: Array<string>): void; export declare function certificatePinningClear(): void; export declare function getCurrentUserAgent(): string; export declare function getCurrentCertificatePinningInstance(): TrustKit | null; export declare const Http: { getFile: typeof getFile; getImage: typeof getImage; getJSON: typeof getJSON; getString: typeof getString; request: typeof request; }; export { ImageCache } from './image-cache';