(req: HttpRequest<any>)
| 404 | } |
| 405 | |
| 406 | private createRequestInit(req: HttpRequest<any>): RequestInit { |
| 407 | if (req.reportUploadProgress) { |
| 408 | throw new RuntimeError( |
| 409 | RuntimeErrorCode.FETCH_UPLOAD_PROGRESS_NOT_SUPPORTED, |
| 410 | ngDevMode && |
| 411 | 'The FetchBackend does not support upload progress reporting. Please use `withXhr()` on your `provideHttpClient()` configuration if you want to report upload progress.', |
| 412 | ); |
| 413 | } |
| 414 | |
| 415 | // We could share some of this logic with the XhrBackend |
| 416 | const headers: Record<string, string> = {}; |
| 417 | let credentials: RequestCredentials | undefined; |
| 418 | |
| 419 | // If the request has a credentials property, use it. |
| 420 | // Otherwise, if the request has withCredentials set to true, use 'include'. |
| 421 | credentials = req.credentials; |
| 422 | |
| 423 | // If withCredentials is true should be set to 'include', for compatibility |
| 424 | if (req.withCredentials) { |
| 425 | // A warning is logged in development mode if the request has both |
| 426 | (typeof ngDevMode === 'undefined' || ngDevMode) && warningOptionsMessage(req); |
| 427 | credentials = 'include'; |
| 428 | } |
| 429 | |
| 430 | // Setting all the requested headers. |
| 431 | req.headers.forEach((name, values) => (headers[name] = values.join(','))); |
| 432 | |
| 433 | // Add an Accept header if one isn't present already. |
| 434 | if (!req.headers.has(ACCEPT_HEADER)) { |
| 435 | headers[ACCEPT_HEADER] = ACCEPT_HEADER_VALUE; |
| 436 | } |
| 437 | |
| 438 | // Auto-detect the Content-Type header if one isn't present already. |
| 439 | if (!req.headers.has(CONTENT_TYPE_HEADER)) { |
| 440 | const detectedType = req.detectContentTypeHeader(); |
| 441 | // Sometimes Content-Type detection fails. |
| 442 | if (detectedType !== null) { |
| 443 | headers[CONTENT_TYPE_HEADER] = detectedType; |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | return { |
| 448 | body: req.serializeBody(), |
| 449 | method: req.method, |
| 450 | headers, |
| 451 | credentials, |
| 452 | keepalive: req.keepalive, |
| 453 | cache: req.cache, |
| 454 | priority: req.priority, |
| 455 | mode: req.mode, |
| 456 | redirect: req.redirect, |
| 457 | referrer: req.referrer, |
| 458 | integrity: req.integrity, |
| 459 | referrerPolicy: req.referrerPolicy, |
| 460 | }; |
| 461 | } |
| 462 | |
| 463 | private concatChunks(chunks: Uint8Array[], totalLength: number): Uint8Array<ArrayBuffer> { |
no test coverage detected