import Task from './async/Task'; import { Handle } from 'dojo-interfaces/core'; import MatchRegistry, { Test } from './MatchRegistry'; import { ParamList } from './UrlSearchParams'; export declare class FilterRegistry extends MatchRegistry { register(test: string | RegExp | RequestFilterTest | null, value: RequestFilter, first?: boolean): Handle; } export declare class ProviderRegistry extends MatchRegistry { private _providerPromise; constructor(); register(test: string | RegExp | RequestProviderTest | null, value: RequestProvider, first?: boolean): Handle; } /** * Request filters, which filter or modify responses. The default filter simply passes a response through unchanged. */ export declare const filterRegistry: FilterRegistry; /** * Request providers, which fulfill requests. */ export declare const providerRegistry: ProviderRegistry; export interface RequestError extends Error { response: Response; } export interface RequestFilter { (response: Response, url: string, options?: RequestOptions): T; } export interface RequestFilterTest extends Test { (response: Response, url: string, options?: RequestOptions): boolean | null; } export interface RequestOptions { auth?: string; cacheBust?: any; data?: any; headers?: { [name: string]: string; }; method?: string; password?: string; query?: string | ParamList; responseType?: string; timeout?: number; user?: string; } export interface RequestProvider { (url: string, options?: RequestOptions): ResponsePromise; } export interface RequestProviderTest extends Test { (url: string, options?: RequestOptions): boolean | null; } export interface Response { data: T | null; nativeResponse?: any; requestOptions: RequestOptions; statusCode: number | null | undefined; statusText?: string | null; url: string; getHeader(name: string): null | string; } /** * The task returned by a request, which will resolve to a Response */ export interface ResponsePromise extends Task> { } /** * Make a request, returning a Promise that will resolve or reject when the request completes. */ declare const request: { (url: string, options?: RequestOptions): ResponsePromise; delete(url: string, options?: RequestOptions): ResponsePromise; get(url: string, options?: RequestOptions): ResponsePromise; post(url: string, options?: RequestOptions): ResponsePromise; put(url: string, options?: RequestOptions): ResponsePromise; }; export default request;