module.d.d.ts 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. /**
  2. * @license Angular v20.1.0
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { ModuleWithProviders } from '@angular/core';
  8. /**
  9. * A token used to manipulate and access values stored in `HttpContext`.
  10. *
  11. * @publicApi
  12. */
  13. declare class HttpContextToken<T> {
  14. readonly defaultValue: () => T;
  15. constructor(defaultValue: () => T);
  16. }
  17. /**
  18. * Http context stores arbitrary user defined values and ensures type safety without
  19. * actually knowing the types. It is backed by a `Map` and guarantees that keys do not clash.
  20. *
  21. * This context is mutable and is shared between cloned requests unless explicitly specified.
  22. *
  23. * @usageNotes
  24. *
  25. * ### Usage Example
  26. *
  27. * ```ts
  28. * // inside cache.interceptors.ts
  29. * export const IS_CACHE_ENABLED = new HttpContextToken<boolean>(() => false);
  30. *
  31. * export class CacheInterceptor implements HttpInterceptor {
  32. *
  33. * intercept(req: HttpRequest<any>, delegate: HttpHandler): Observable<HttpEvent<any>> {
  34. * if (req.context.get(IS_CACHE_ENABLED) === true) {
  35. * return ...;
  36. * }
  37. * return delegate.handle(req);
  38. * }
  39. * }
  40. *
  41. * // inside a service
  42. *
  43. * this.httpClient.get('/api/weather', {
  44. * context: new HttpContext().set(IS_CACHE_ENABLED, true)
  45. * }).subscribe(...);
  46. * ```
  47. *
  48. * @publicApi
  49. */
  50. declare class HttpContext {
  51. private readonly map;
  52. /**
  53. * Store a value in the context. If a value is already present it will be overwritten.
  54. *
  55. * @param token The reference to an instance of `HttpContextToken`.
  56. * @param value The value to store.
  57. *
  58. * @returns A reference to itself for easy chaining.
  59. */
  60. set<T>(token: HttpContextToken<T>, value: T): HttpContext;
  61. /**
  62. * Retrieve the value associated with the given token.
  63. *
  64. * @param token The reference to an instance of `HttpContextToken`.
  65. *
  66. * @returns The stored value or default if one is defined.
  67. */
  68. get<T>(token: HttpContextToken<T>): T;
  69. /**
  70. * Delete the value associated with the given token.
  71. *
  72. * @param token The reference to an instance of `HttpContextToken`.
  73. *
  74. * @returns A reference to itself for easy chaining.
  75. */
  76. delete(token: HttpContextToken<unknown>): HttpContext;
  77. /**
  78. * Checks for existence of a given token.
  79. *
  80. * @param token The reference to an instance of `HttpContextToken`.
  81. *
  82. * @returns True if the token exists, false otherwise.
  83. */
  84. has(token: HttpContextToken<unknown>): boolean;
  85. /**
  86. * @returns a list of tokens currently stored in the context.
  87. */
  88. keys(): IterableIterator<HttpContextToken<unknown>>;
  89. }
  90. /**
  91. * Represents the header configuration options for an HTTP request.
  92. * Instances are immutable. Modifying methods return a cloned
  93. * instance with the change. The original object is never changed.
  94. *
  95. * @publicApi
  96. */
  97. declare class HttpHeaders {
  98. /**
  99. * Internal map of lowercase header names to values.
  100. */
  101. private headers;
  102. /**
  103. * Internal map of lowercased header names to the normalized
  104. * form of the name (the form seen first).
  105. */
  106. private normalizedNames;
  107. /**
  108. * Complete the lazy initialization of this object (needed before reading).
  109. */
  110. private lazyInit;
  111. /**
  112. * Queued updates to be materialized the next initialization.
  113. */
  114. private lazyUpdate;
  115. /** Constructs a new HTTP header object with the given values.*/
  116. constructor(headers?: string | {
  117. [name: string]: string | number | (string | number)[];
  118. } | Headers);
  119. /**
  120. * Checks for existence of a given header.
  121. *
  122. * @param name The header name to check for existence.
  123. *
  124. * @returns True if the header exists, false otherwise.
  125. */
  126. has(name: string): boolean;
  127. /**
  128. * Retrieves the first value of a given header.
  129. *
  130. * @param name The header name.
  131. *
  132. * @returns The value string if the header exists, null otherwise
  133. */
  134. get(name: string): string | null;
  135. /**
  136. * Retrieves the names of the headers.
  137. *
  138. * @returns A list of header names.
  139. */
  140. keys(): string[];
  141. /**
  142. * Retrieves a list of values for a given header.
  143. *
  144. * @param name The header name from which to retrieve values.
  145. *
  146. * @returns A string of values if the header exists, null otherwise.
  147. */
  148. getAll(name: string): string[] | null;
  149. /**
  150. * Appends a new value to the existing set of values for a header
  151. * and returns them in a clone of the original instance.
  152. *
  153. * @param name The header name for which to append the values.
  154. * @param value The value to append.
  155. *
  156. * @returns A clone of the HTTP headers object with the value appended to the given header.
  157. */
  158. append(name: string, value: string | string[]): HttpHeaders;
  159. /**
  160. * Sets or modifies a value for a given header in a clone of the original instance.
  161. * If the header already exists, its value is replaced with the given value
  162. * in the returned object.
  163. *
  164. * @param name The header name.
  165. * @param value The value or values to set or override for the given header.
  166. *
  167. * @returns A clone of the HTTP headers object with the newly set header value.
  168. */
  169. set(name: string, value: string | string[]): HttpHeaders;
  170. /**
  171. * Deletes values for a given header in a clone of the original instance.
  172. *
  173. * @param name The header name.
  174. * @param value The value or values to delete for the given header.
  175. *
  176. * @returns A clone of the HTTP headers object with the given value deleted.
  177. */
  178. delete(name: string, value?: string | string[]): HttpHeaders;
  179. private maybeSetNormalizedName;
  180. private init;
  181. private copyFrom;
  182. private clone;
  183. private applyUpdate;
  184. private addHeaderEntry;
  185. private setHeaderEntries;
  186. }
  187. /**
  188. * A codec for encoding and decoding parameters in URLs.
  189. *
  190. * Used by `HttpParams`.
  191. *
  192. * @publicApi
  193. **/
  194. interface HttpParameterCodec {
  195. encodeKey(key: string): string;
  196. encodeValue(value: string): string;
  197. decodeKey(key: string): string;
  198. decodeValue(value: string): string;
  199. }
  200. /**
  201. * Provides encoding and decoding of URL parameter and query-string values.
  202. *
  203. * Serializes and parses URL parameter keys and values to encode and decode them.
  204. * If you pass URL query parameters without encoding,
  205. * the query parameters can be misinterpreted at the receiving end.
  206. *
  207. *
  208. * @publicApi
  209. */
  210. declare class HttpUrlEncodingCodec implements HttpParameterCodec {
  211. /**
  212. * Encodes a key name for a URL parameter or query-string.
  213. * @param key The key name.
  214. * @returns The encoded key name.
  215. */
  216. encodeKey(key: string): string;
  217. /**
  218. * Encodes the value of a URL parameter or query-string.
  219. * @param value The value.
  220. * @returns The encoded value.
  221. */
  222. encodeValue(value: string): string;
  223. /**
  224. * Decodes an encoded URL parameter or query-string key.
  225. * @param key The encoded key name.
  226. * @returns The decoded key name.
  227. */
  228. decodeKey(key: string): string;
  229. /**
  230. * Decodes an encoded URL parameter or query-string value.
  231. * @param value The encoded value.
  232. * @returns The decoded value.
  233. */
  234. decodeValue(value: string): string;
  235. }
  236. /**
  237. * Options used to construct an `HttpParams` instance.
  238. *
  239. * @publicApi
  240. */
  241. interface HttpParamsOptions {
  242. /**
  243. * String representation of the HTTP parameters in URL-query-string format.
  244. * Mutually exclusive with `fromObject`.
  245. */
  246. fromString?: string;
  247. /** Object map of the HTTP parameters. Mutually exclusive with `fromString`. */
  248. fromObject?: {
  249. [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
  250. };
  251. /** Encoding codec used to parse and serialize the parameters. */
  252. encoder?: HttpParameterCodec;
  253. }
  254. /**
  255. * An HTTP request/response body that represents serialized parameters,
  256. * per the MIME type `application/x-www-form-urlencoded`.
  257. *
  258. * This class is immutable; all mutation operations return a new instance.
  259. *
  260. * @publicApi
  261. */
  262. declare class HttpParams {
  263. private map;
  264. private encoder;
  265. private updates;
  266. private cloneFrom;
  267. constructor(options?: HttpParamsOptions);
  268. /**
  269. * Reports whether the body includes one or more values for a given parameter.
  270. * @param param The parameter name.
  271. * @returns True if the parameter has one or more values,
  272. * false if it has no value or is not present.
  273. */
  274. has(param: string): boolean;
  275. /**
  276. * Retrieves the first value for a parameter.
  277. * @param param The parameter name.
  278. * @returns The first value of the given parameter,
  279. * or `null` if the parameter is not present.
  280. */
  281. get(param: string): string | null;
  282. /**
  283. * Retrieves all values for a parameter.
  284. * @param param The parameter name.
  285. * @returns All values in a string array,
  286. * or `null` if the parameter not present.
  287. */
  288. getAll(param: string): string[] | null;
  289. /**
  290. * Retrieves all the parameters for this body.
  291. * @returns The parameter names in a string array.
  292. */
  293. keys(): string[];
  294. /**
  295. * Appends a new value to existing values for a parameter.
  296. * @param param The parameter name.
  297. * @param value The new value to add.
  298. * @return A new body with the appended value.
  299. */
  300. append(param: string, value: string | number | boolean): HttpParams;
  301. /**
  302. * Constructs a new body with appended values for the given parameter name.
  303. * @param params parameters and values
  304. * @return A new body with the new value.
  305. */
  306. appendAll(params: {
  307. [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
  308. }): HttpParams;
  309. /**
  310. * Replaces the value for a parameter.
  311. * @param param The parameter name.
  312. * @param value The new value.
  313. * @return A new body with the new value.
  314. */
  315. set(param: string, value: string | number | boolean): HttpParams;
  316. /**
  317. * Removes a given value or all values from a parameter.
  318. * @param param The parameter name.
  319. * @param value The value to remove, if provided.
  320. * @return A new body with the given value removed, or with all values
  321. * removed if no value is specified.
  322. */
  323. delete(param: string, value?: string | number | boolean): HttpParams;
  324. /**
  325. * Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
  326. * separated by `&`s.
  327. */
  328. toString(): string;
  329. private clone;
  330. private init;
  331. }
  332. /**
  333. * An outgoing HTTP request with an optional typed body.
  334. *
  335. * `HttpRequest` represents an outgoing request, including URL, method,
  336. * headers, body, and other request configuration options. Instances should be
  337. * assumed to be immutable. To modify a `HttpRequest`, the `clone`
  338. * method should be used.
  339. *
  340. * @publicApi
  341. */
  342. declare class HttpRequest<T> {
  343. readonly url: string;
  344. /**
  345. * The request body, or `null` if one isn't set.
  346. *
  347. * Bodies are not enforced to be immutable, as they can include a reference to any
  348. * user-defined data type. However, interceptors should take care to preserve
  349. * idempotence by treating them as such.
  350. */
  351. readonly body: T | null;
  352. /**
  353. * Outgoing headers for this request.
  354. */
  355. readonly headers: HttpHeaders;
  356. /**
  357. * Shared and mutable context that can be used by interceptors
  358. */
  359. readonly context: HttpContext;
  360. /**
  361. * Whether this request should be made in a way that exposes progress events.
  362. *
  363. * Progress events are expensive (change detection runs on each event) and so
  364. * they should only be requested if the consumer intends to monitor them.
  365. *
  366. * Note: The `FetchBackend` doesn't support progress report on uploads.
  367. */
  368. readonly reportProgress: boolean;
  369. /**
  370. * Whether this request should be sent with outgoing credentials (cookies).
  371. */
  372. readonly withCredentials: boolean;
  373. /**
  374. * The credentials mode of the request, which determines how cookies and HTTP authentication are handled.
  375. * This can affect whether cookies are sent with the request, and how authentication is handled.
  376. */
  377. readonly credentials: RequestCredentials;
  378. /**
  379. * When using the fetch implementation and set to `true`, the browser will not abort the associated request if the page that initiated it is unloaded before the request is complete.
  380. */
  381. readonly keepalive: boolean;
  382. /**
  383. * Controls how the request will interact with the browser's HTTP cache.
  384. * This affects whether a response is retrieved from the cache, how it is stored, or if it bypasses the cache altogether.
  385. */
  386. readonly cache: RequestCache;
  387. /**
  388. * Indicates the relative priority of the request. This may be used by the browser to decide the order in which requests are dispatched and resources fetched.
  389. */
  390. readonly priority: RequestPriority;
  391. /**
  392. * The mode of the request, which determines how the request will interact with the browser's security model.
  393. * This can affect things like CORS (Cross-Origin Resource Sharing) and same-origin policies.
  394. */
  395. readonly mode: RequestMode;
  396. /**
  397. * The redirect mode of the request, which determines how redirects are handled.
  398. * This can affect whether the request follows redirects automatically, or if it fails when a redirect occurs.
  399. */
  400. readonly redirect: RequestRedirect;
  401. /**
  402. * The expected response type of the server.
  403. *
  404. * This is used to parse the response appropriately before returning it to
  405. * the requestee.
  406. */
  407. readonly responseType: 'arraybuffer' | 'blob' | 'json' | 'text';
  408. /**
  409. * The outgoing HTTP request method.
  410. */
  411. readonly method: string;
  412. /**
  413. * Outgoing URL parameters.
  414. *
  415. * To pass a string representation of HTTP parameters in the URL-query-string format,
  416. * the `HttpParamsOptions`' `fromString` may be used. For example:
  417. *
  418. * ```ts
  419. * new HttpParams({fromString: 'angular=awesome'})
  420. * ```
  421. */
  422. readonly params: HttpParams;
  423. /**
  424. * The outgoing URL with all URL parameters set.
  425. */
  426. readonly urlWithParams: string;
  427. /**
  428. * The HttpTransferCache option for the request
  429. */
  430. readonly transferCache?: {
  431. includeHeaders?: string[];
  432. } | boolean;
  433. /**
  434. * The timeout for the backend HTTP request in ms.
  435. */
  436. readonly timeout?: number;
  437. constructor(method: 'GET' | 'HEAD', url: string, init?: {
  438. headers?: HttpHeaders;
  439. context?: HttpContext;
  440. reportProgress?: boolean;
  441. params?: HttpParams;
  442. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  443. withCredentials?: boolean;
  444. credentials?: RequestCredentials;
  445. keepalive?: boolean;
  446. priority?: RequestPriority;
  447. cache?: RequestCache;
  448. mode?: RequestMode;
  449. redirect?: RequestRedirect;
  450. /**
  451. * This property accepts either a boolean to enable/disable transferring cache for eligible
  452. * requests performed using `HttpClient`, or an object, which allows to configure cache
  453. * parameters, such as which headers should be included (no headers are included by default).
  454. *
  455. * Setting this property will override the options passed to `provideClientHydration()` for this
  456. * particular request
  457. */
  458. transferCache?: {
  459. includeHeaders?: string[];
  460. } | boolean;
  461. timeout?: number;
  462. });
  463. constructor(method: 'DELETE' | 'JSONP' | 'OPTIONS', url: string, init?: {
  464. headers?: HttpHeaders;
  465. context?: HttpContext;
  466. reportProgress?: boolean;
  467. params?: HttpParams;
  468. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  469. withCredentials?: boolean;
  470. credentials?: RequestCredentials;
  471. keepalive?: boolean;
  472. priority?: RequestPriority;
  473. cache?: RequestCache;
  474. timeout?: number;
  475. mode?: RequestMode;
  476. redirect?: RequestRedirect;
  477. });
  478. constructor(method: 'POST', url: string, body: T | null, init?: {
  479. headers?: HttpHeaders;
  480. context?: HttpContext;
  481. reportProgress?: boolean;
  482. params?: HttpParams;
  483. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  484. withCredentials?: boolean;
  485. credentials?: RequestCredentials;
  486. keepalive?: boolean;
  487. priority?: RequestPriority;
  488. cache?: RequestCache;
  489. mode?: RequestMode;
  490. redirect?: RequestRedirect;
  491. /**
  492. * This property accepts either a boolean to enable/disable transferring cache for eligible
  493. * requests performed using `HttpClient`, or an object, which allows to configure cache
  494. * parameters, such as which headers should be included (no headers are included by default).
  495. *
  496. * Setting this property will override the options passed to `provideClientHydration()` for this
  497. * particular request
  498. */
  499. transferCache?: {
  500. includeHeaders?: string[];
  501. } | boolean;
  502. timeout?: number;
  503. });
  504. constructor(method: 'PUT' | 'PATCH', url: string, body: T | null, init?: {
  505. headers?: HttpHeaders;
  506. context?: HttpContext;
  507. reportProgress?: boolean;
  508. params?: HttpParams;
  509. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  510. withCredentials?: boolean;
  511. credentials?: RequestCredentials;
  512. keepalive?: boolean;
  513. priority?: RequestPriority;
  514. cache?: RequestCache;
  515. timeout?: number;
  516. mode?: RequestMode;
  517. redirect?: RequestRedirect;
  518. });
  519. constructor(method: string, url: string, body: T | null, init?: {
  520. headers?: HttpHeaders;
  521. context?: HttpContext;
  522. reportProgress?: boolean;
  523. params?: HttpParams;
  524. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  525. withCredentials?: boolean;
  526. credentials?: RequestCredentials;
  527. keepalive?: boolean;
  528. priority?: RequestPriority;
  529. cache?: RequestCache;
  530. mode?: RequestMode;
  531. redirect?: RequestRedirect;
  532. /**
  533. * This property accepts either a boolean to enable/disable transferring cache for eligible
  534. * requests performed using `HttpClient`, or an object, which allows to configure cache
  535. * parameters, such as which headers should be included (no headers are included by default).
  536. *
  537. * Setting this property will override the options passed to `provideClientHydration()` for this
  538. * particular request
  539. */
  540. transferCache?: {
  541. includeHeaders?: string[];
  542. } | boolean;
  543. timeout?: number;
  544. });
  545. /**
  546. * Transform the free-form body into a serialized format suitable for
  547. * transmission to the server.
  548. */
  549. serializeBody(): ArrayBuffer | Blob | FormData | URLSearchParams | string | null;
  550. /**
  551. * Examine the body and attempt to infer an appropriate MIME type
  552. * for it.
  553. *
  554. * If no such type can be inferred, this method will return `null`.
  555. */
  556. detectContentTypeHeader(): string | null;
  557. clone(): HttpRequest<T>;
  558. clone(update: {
  559. headers?: HttpHeaders;
  560. context?: HttpContext;
  561. reportProgress?: boolean;
  562. params?: HttpParams;
  563. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  564. withCredentials?: boolean;
  565. credentials?: RequestCredentials;
  566. keepalive?: boolean;
  567. priority?: RequestPriority;
  568. cache?: RequestCache;
  569. mode?: RequestMode;
  570. redirect?: RequestRedirect;
  571. transferCache?: {
  572. includeHeaders?: string[];
  573. } | boolean;
  574. timeout?: number;
  575. body?: T | null;
  576. method?: string;
  577. url?: string;
  578. setHeaders?: {
  579. [name: string]: string | string[];
  580. };
  581. setParams?: {
  582. [param: string]: string;
  583. };
  584. }): HttpRequest<T>;
  585. clone<V>(update: {
  586. headers?: HttpHeaders;
  587. context?: HttpContext;
  588. reportProgress?: boolean;
  589. params?: HttpParams;
  590. responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
  591. keepalive?: boolean;
  592. priority?: RequestPriority;
  593. cache?: RequestCache;
  594. mode?: RequestMode;
  595. redirect?: RequestRedirect;
  596. withCredentials?: boolean;
  597. credentials?: RequestCredentials;
  598. transferCache?: {
  599. includeHeaders?: string[];
  600. } | boolean;
  601. timeout?: number;
  602. body?: V | null;
  603. method?: string;
  604. url?: string;
  605. setHeaders?: {
  606. [name: string]: string | string[];
  607. };
  608. setParams?: {
  609. [param: string]: string;
  610. };
  611. }): HttpRequest<V>;
  612. }
  613. /**
  614. * Type enumeration for the different kinds of `HttpEvent`.
  615. *
  616. * @publicApi
  617. */
  618. declare enum HttpEventType {
  619. /**
  620. * The request was sent out over the wire.
  621. */
  622. Sent = 0,
  623. /**
  624. * An upload progress event was received.
  625. *
  626. * Note: The `FetchBackend` doesn't support progress report on uploads.
  627. */
  628. UploadProgress = 1,
  629. /**
  630. * The response status code and headers were received.
  631. */
  632. ResponseHeader = 2,
  633. /**
  634. * A download progress event was received.
  635. */
  636. DownloadProgress = 3,
  637. /**
  638. * The full response including the body was received.
  639. */
  640. Response = 4,
  641. /**
  642. * A custom event from an interceptor or a backend.
  643. */
  644. User = 5
  645. }
  646. /**
  647. * Base interface for progress events.
  648. *
  649. * @publicApi
  650. */
  651. interface HttpProgressEvent {
  652. /**
  653. * Progress event type is either upload or download.
  654. */
  655. type: HttpEventType.DownloadProgress | HttpEventType.UploadProgress;
  656. /**
  657. * Number of bytes uploaded or downloaded.
  658. */
  659. loaded: number;
  660. /**
  661. * Total number of bytes to upload or download. Depending on the request or
  662. * response, this may not be computable and thus may not be present.
  663. */
  664. total?: number;
  665. }
  666. /**
  667. * A download progress event.
  668. *
  669. * @publicApi
  670. */
  671. interface HttpDownloadProgressEvent extends HttpProgressEvent {
  672. type: HttpEventType.DownloadProgress;
  673. /**
  674. * The partial response body as downloaded so far.
  675. *
  676. * Only present if the responseType was `text`.
  677. */
  678. partialText?: string;
  679. }
  680. /**
  681. * An upload progress event.
  682. *
  683. * Note: The `FetchBackend` doesn't support progress report on uploads.
  684. *
  685. * @publicApi
  686. */
  687. interface HttpUploadProgressEvent extends HttpProgressEvent {
  688. type: HttpEventType.UploadProgress;
  689. }
  690. /**
  691. * An event indicating that the request was sent to the server. Useful
  692. * when a request may be retried multiple times, to distinguish between
  693. * retries on the final event stream.
  694. *
  695. * @publicApi
  696. */
  697. interface HttpSentEvent {
  698. type: HttpEventType.Sent;
  699. }
  700. /**
  701. * A user-defined event.
  702. *
  703. * Grouping all custom events under this type ensures they will be handled
  704. * and forwarded by all implementations of interceptors.
  705. *
  706. * @publicApi
  707. */
  708. interface HttpUserEvent<T> {
  709. type: HttpEventType.User;
  710. }
  711. /**
  712. * Union type for all possible events on the response stream.
  713. *
  714. * Typed according to the expected type of the response.
  715. *
  716. * @publicApi
  717. */
  718. type HttpEvent<T> = HttpSentEvent | HttpHeaderResponse | HttpResponse<T> | HttpProgressEvent | HttpUserEvent<T>;
  719. /**
  720. * Base class for both `HttpResponse` and `HttpHeaderResponse`.
  721. *
  722. * @publicApi
  723. */
  724. declare abstract class HttpResponseBase {
  725. /**
  726. * All response headers.
  727. */
  728. readonly headers: HttpHeaders;
  729. /**
  730. * Response status code.
  731. */
  732. readonly status: number;
  733. /**
  734. * Textual description of response status code, defaults to OK.
  735. *
  736. * Do not depend on this.
  737. */
  738. readonly statusText: string;
  739. /**
  740. * URL of the resource retrieved, or null if not available.
  741. */
  742. readonly url: string | null;
  743. /**
  744. * Whether the status code falls in the 2xx range.
  745. */
  746. readonly ok: boolean;
  747. /**
  748. * Type of the response, narrowed to either the full response or the header.
  749. */
  750. readonly type: HttpEventType.Response | HttpEventType.ResponseHeader;
  751. /**
  752. * Super-constructor for all responses.
  753. *
  754. * The single parameter accepted is an initialization hash. Any properties
  755. * of the response passed there will override the default values.
  756. */
  757. constructor(init: {
  758. headers?: HttpHeaders;
  759. status?: number;
  760. statusText?: string;
  761. url?: string;
  762. }, defaultStatus?: number, defaultStatusText?: string);
  763. }
  764. /**
  765. * A partial HTTP response which only includes the status and header data,
  766. * but no response body.
  767. *
  768. * `HttpHeaderResponse` is a `HttpEvent` available on the response
  769. * event stream, only when progress events are requested.
  770. *
  771. * @publicApi
  772. */
  773. declare class HttpHeaderResponse extends HttpResponseBase {
  774. /**
  775. * Create a new `HttpHeaderResponse` with the given parameters.
  776. */
  777. constructor(init?: {
  778. headers?: HttpHeaders;
  779. status?: number;
  780. statusText?: string;
  781. url?: string;
  782. });
  783. readonly type: HttpEventType.ResponseHeader;
  784. /**
  785. * Copy this `HttpHeaderResponse`, overriding its contents with the
  786. * given parameter hash.
  787. */
  788. clone(update?: {
  789. headers?: HttpHeaders;
  790. status?: number;
  791. statusText?: string;
  792. url?: string;
  793. }): HttpHeaderResponse;
  794. }
  795. /**
  796. * A full HTTP response, including a typed response body (which may be `null`
  797. * if one was not returned).
  798. *
  799. * `HttpResponse` is a `HttpEvent` available on the response event
  800. * stream.
  801. *
  802. * @publicApi
  803. */
  804. declare class HttpResponse<T> extends HttpResponseBase {
  805. /**
  806. * The response body, or `null` if one was not returned.
  807. */
  808. readonly body: T | null;
  809. /**
  810. * Construct a new `HttpResponse`.
  811. */
  812. constructor(init?: {
  813. body?: T | null;
  814. headers?: HttpHeaders;
  815. status?: number;
  816. statusText?: string;
  817. url?: string;
  818. });
  819. readonly type: HttpEventType.Response;
  820. clone(): HttpResponse<T>;
  821. clone(update: {
  822. headers?: HttpHeaders;
  823. status?: number;
  824. statusText?: string;
  825. url?: string;
  826. }): HttpResponse<T>;
  827. clone<V>(update: {
  828. body?: V | null;
  829. headers?: HttpHeaders;
  830. status?: number;
  831. statusText?: string;
  832. url?: string;
  833. }): HttpResponse<V>;
  834. }
  835. /**
  836. * A response that represents an error or failure, either from a
  837. * non-successful HTTP status, an error while executing the request,
  838. * or some other failure which occurred during the parsing of the response.
  839. *
  840. * Any error returned on the `Observable` response stream will be
  841. * wrapped in an `HttpErrorResponse` to provide additional context about
  842. * the state of the HTTP layer when the error occurred. The error property
  843. * will contain either a wrapped Error object or the error response returned
  844. * from the server.
  845. *
  846. * @publicApi
  847. */
  848. declare class HttpErrorResponse extends HttpResponseBase implements Error {
  849. readonly name = "HttpErrorResponse";
  850. readonly message: string;
  851. readonly error: any | null;
  852. /**
  853. * Errors are never okay, even when the status code is in the 2xx success range.
  854. */
  855. readonly ok = false;
  856. constructor(init: {
  857. error?: any;
  858. headers?: HttpHeaders;
  859. status?: number;
  860. statusText?: string;
  861. url?: string;
  862. });
  863. }
  864. /**
  865. * Http status codes.
  866. * As per https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
  867. * @publicApi
  868. */
  869. declare enum HttpStatusCode {
  870. Continue = 100,
  871. SwitchingProtocols = 101,
  872. Processing = 102,
  873. EarlyHints = 103,
  874. Ok = 200,
  875. Created = 201,
  876. Accepted = 202,
  877. NonAuthoritativeInformation = 203,
  878. NoContent = 204,
  879. ResetContent = 205,
  880. PartialContent = 206,
  881. MultiStatus = 207,
  882. AlreadyReported = 208,
  883. ImUsed = 226,
  884. MultipleChoices = 300,
  885. MovedPermanently = 301,
  886. Found = 302,
  887. SeeOther = 303,
  888. NotModified = 304,
  889. UseProxy = 305,
  890. Unused = 306,
  891. TemporaryRedirect = 307,
  892. PermanentRedirect = 308,
  893. BadRequest = 400,
  894. Unauthorized = 401,
  895. PaymentRequired = 402,
  896. Forbidden = 403,
  897. NotFound = 404,
  898. MethodNotAllowed = 405,
  899. NotAcceptable = 406,
  900. ProxyAuthenticationRequired = 407,
  901. RequestTimeout = 408,
  902. Conflict = 409,
  903. Gone = 410,
  904. LengthRequired = 411,
  905. PreconditionFailed = 412,
  906. PayloadTooLarge = 413,
  907. UriTooLong = 414,
  908. UnsupportedMediaType = 415,
  909. RangeNotSatisfiable = 416,
  910. ExpectationFailed = 417,
  911. ImATeapot = 418,
  912. MisdirectedRequest = 421,
  913. UnprocessableEntity = 422,
  914. Locked = 423,
  915. FailedDependency = 424,
  916. TooEarly = 425,
  917. UpgradeRequired = 426,
  918. PreconditionRequired = 428,
  919. TooManyRequests = 429,
  920. RequestHeaderFieldsTooLarge = 431,
  921. UnavailableForLegalReasons = 451,
  922. InternalServerError = 500,
  923. NotImplemented = 501,
  924. BadGateway = 502,
  925. ServiceUnavailable = 503,
  926. GatewayTimeout = 504,
  927. HttpVersionNotSupported = 505,
  928. VariantAlsoNegotiates = 506,
  929. InsufficientStorage = 507,
  930. LoopDetected = 508,
  931. NotExtended = 510,
  932. NetworkAuthenticationRequired = 511
  933. }
  934. /**
  935. * Configures XSRF protection support for outgoing requests.
  936. *
  937. * For a server that supports a cookie-based XSRF protection system,
  938. * use directly to configure XSRF protection with the correct
  939. * cookie and header names.
  940. *
  941. * If no names are supplied, the default cookie name is `XSRF-TOKEN`
  942. * and the default header name is `X-XSRF-TOKEN`.
  943. *
  944. * @publicApi
  945. * @deprecated Use withXsrfConfiguration({cookieName: 'XSRF-TOKEN', headerName: 'X-XSRF-TOKEN'}) as
  946. * providers instead or `withNoXsrfProtection` if you want to disabled XSRF protection.
  947. */
  948. declare class HttpClientXsrfModule {
  949. /**
  950. * Disable the default XSRF protection.
  951. */
  952. static disable(): ModuleWithProviders<HttpClientXsrfModule>;
  953. /**
  954. * Configure XSRF protection.
  955. * @param options An object that can specify either or both
  956. * cookie name or header name.
  957. * - Cookie name default is `XSRF-TOKEN`.
  958. * - Header name default is `X-XSRF-TOKEN`.
  959. *
  960. */
  961. static withOptions(options?: {
  962. cookieName?: string;
  963. headerName?: string;
  964. }): ModuleWithProviders<HttpClientXsrfModule>;
  965. static ɵfac: i0.ɵɵFactoryDeclaration<HttpClientXsrfModule, never>;
  966. static ɵmod: i0.ɵɵNgModuleDeclaration<HttpClientXsrfModule, never, never, never>;
  967. static ɵinj: i0.ɵɵInjectorDeclaration<HttpClientXsrfModule>;
  968. }
  969. /**
  970. * Configures the dependency injector for `HttpClient`
  971. * with supporting services for XSRF. Automatically imported by `HttpClientModule`.
  972. *
  973. * You can add interceptors to the chain behind `HttpClient` by binding them to the
  974. * multiprovider for built-in DI token `HTTP_INTERCEPTORS`.
  975. *
  976. * @publicApi
  977. * @deprecated use `provideHttpClient(withInterceptorsFromDi())` as providers instead
  978. */
  979. declare class HttpClientModule {
  980. static ɵfac: i0.ɵɵFactoryDeclaration<HttpClientModule, never>;
  981. static ɵmod: i0.ɵɵNgModuleDeclaration<HttpClientModule, never, never, never>;
  982. static ɵinj: i0.ɵɵInjectorDeclaration<HttpClientModule>;
  983. }
  984. /**
  985. * Configures the dependency injector for `HttpClient`
  986. * with supporting services for JSONP.
  987. * Without this module, Jsonp requests reach the backend
  988. * with method JSONP, where they are rejected.
  989. *
  990. * @publicApi
  991. * @deprecated `withJsonpSupport()` as providers instead
  992. */
  993. declare class HttpClientJsonpModule {
  994. static ɵfac: i0.ɵɵFactoryDeclaration<HttpClientJsonpModule, never>;
  995. static ɵmod: i0.ɵɵNgModuleDeclaration<HttpClientJsonpModule, never, never, never>;
  996. static ɵinj: i0.ɵɵInjectorDeclaration<HttpClientJsonpModule>;
  997. }
  998. export { HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContext, HttpContextToken, HttpErrorResponse, HttpEventType, HttpHeaderResponse, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpResponseBase, HttpStatusCode, HttpUrlEncodingCodec };
  999. export type { HttpDownloadProgressEvent, HttpEvent, HttpParameterCodec, HttpParamsOptions, HttpProgressEvent, HttpSentEvent, HttpUploadProgressEvent, HttpUserEvent };