import type { SafeAny } from '@ngify/core'; import { HttpHeaders } from './headers'; export type HttpEvent = HttpSentEvent | HttpHeaderResponse | HttpResponse | HttpProgressEvent | HttpUserEvent; /** Type enumeration for the different kinds of `HttpEvent`. */ export declare enum HttpEventType { /** The request was sent out over the wire. */ Sent = 0, /** An upload progress event was received. */ UploadProgress = 1, /** The response status code and headers were received. */ ResponseHeader = 2, /** A download progress event was received. */ DownloadProgress = 3, /** The full response including the body was received. */ Response = 4, /** A custom event from an interceptor or a backend. */ User = 5 } /** Base interface for progress events. */ export interface HttpProgressEvent { /** Progress event type is either upload or download. */ type: HttpEventType.DownloadProgress | HttpEventType.UploadProgress; /** Number of bytes uploaded or downloaded. */ loaded: number; /** Total number of bytes to upload or download. Depending on the request or response */ total?: number; } /** A download progress event. */ export interface HttpDownloadProgressEvent extends HttpProgressEvent { type: HttpEventType.DownloadProgress; /** The partial response body as downloaded so far. Only present if the responseType was `text`. */ partialText?: string; } /** An upload progress event. */ export interface HttpUploadProgressEvent extends HttpProgressEvent { type: HttpEventType.UploadProgress; } /** An event indicating that the request was sent to the server */ export interface HttpSentEvent { type: HttpEventType.Sent; } /** A user-defined event. */ export interface HttpUserEvent { type: HttpEventType.User; } /** An error that represents a failed attempt to JSON.parse text coming back from the server. */ export interface HttpJsonParseError { error: Error; text: string; } /** Base class for both `HttpResponse` and `HttpHeaderResponse`. */ export declare abstract class HttpResponseBase { readonly ok: boolean; readonly url: string | null; readonly status: number; readonly statusText: string; readonly headers: HttpHeaders; readonly type: HttpEventType.Response | HttpEventType.ResponseHeader; constructor(options: { url?: string; status?: number; statusText?: string; headers?: HttpHeaders; }, defaultStatus?: number, defaultStatusText?: string); } export declare class HttpHeaderResponse extends HttpResponseBase { readonly type: HttpEventType.ResponseHeader; constructor(options?: { url?: string; status?: number; statusText?: string; headers?: HttpHeaders; }); clone(update?: ConstructorParameters[0]): HttpHeaderResponse; } export declare class HttpResponse extends HttpResponseBase { readonly body: T | null; readonly type: HttpEventType.Response; constructor(options?: { url?: string; body?: T | null; status?: number; statusText?: string; headers?: HttpHeaders; }); clone(update?: ConstructorParameters[0]): HttpResponse; } export declare class HttpErrorResponse extends HttpResponseBase implements Error { readonly name = "HttpErrorResponse"; readonly message: string; readonly error: SafeAny | null; readonly ok = false; constructor(options: { url?: string; error?: SafeAny; headers?: HttpHeaders; status?: number; statusText?: string; }); } /** * We use these constant to prevent pulling the whole HttpStatusCode enum * Those are the only ones referenced directly by the framework */ export declare const HTTP_STATUS_CODE_OK = 200; export declare const HTTP_STATUS_CODE_NO_CONTENT = 204; /** * Http status codes. * As per https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * @publicApi */ export declare enum HttpStatusCode { Continue = 100, SwitchingProtocols = 101, Processing = 102, EarlyHints = 103, Ok = 200, Created = 201, Accepted = 202, NonAuthoritativeInformation = 203, NoContent = 204, ResetContent = 205, PartialContent = 206, MultiStatus = 207, AlreadyReported = 208, ImUsed = 226, MultipleChoices = 300, MovedPermanently = 301, Found = 302, SeeOther = 303, NotModified = 304, UseProxy = 305, Unused = 306, TemporaryRedirect = 307, PermanentRedirect = 308, BadRequest = 400, Unauthorized = 401, PaymentRequired = 402, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407, RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411, PreconditionFailed = 412, PayloadTooLarge = 413, UriTooLong = 414, UnsupportedMediaType = 415, RangeNotSatisfiable = 416, ExpectationFailed = 417, ImATeapot = 418, MisdirectedRequest = 421, UnprocessableEntity = 422, Locked = 423, FailedDependency = 424, TooEarly = 425, UpgradeRequired = 426, PreconditionRequired = 428, TooManyRequests = 429, RequestHeaderFieldsTooLarge = 431, UnavailableForLegalReasons = 451, InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HttpVersionNotSupported = 505, VariantAlsoNegotiates = 506, InsufficientStorage = 507, LoopDetected = 508, NotExtended = 510, NetworkAuthenticationRequired = 511 }