8000 feat(http): add timeout option on httpResource. (#62326) · angular/angular@aa861c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa861c4

Browse files
JeanMechethePunderWoman
authored andcommitted
feat(http): add timeout option on httpResource. (#62326)
This uses the option that was introduction on the HttpClient PR Close #62326
1 parent 0390bd9 commit aa861c4

File tree

4 files changed

+9
-0
lines changed
  • goldens/public-api/common/http
  • packages/common/http

4 files changed

+9
-0
lines changed

goldens/public-api/common/http/index.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,7 @@ export interface HttpResourceRequest {
21432143
params?: HttpParams | Record<string, string | number | boolean | ReadonlyArray<string | number | boolean>>;
21442144
priority?: RequestPriority | (string & {});
21452145
reportProgress?: boolean;
2146+
timeout?: number;
21462147
transferCache?: {
21472148
includeHeaders?: string[];
21482149
} | boolean;

packages/common/http/src/resource.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ function normalizeRequest(
284284
responseType,
285285
context: unwrappedRequest.context,
286286
transferCache: unwrappedRequest.transferCache,
287+
timeout: unwrappedRequest.timeout,
287288
},
288289
);
289290
}

packages/common/http/src/resource_api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export interface HttpResourceRequest {
9292
* See the documentation on the transfer cache for more information.
9393
*/
9494
transferCache?: {includeHeaders?: string[]} | boolean;
95+
96+
/**
97+
* The timeout for the backend HTTP request in ms.
98+
*/
99+
timeout?: number;
95100
}
96101

97102
/**

packages/common/http/test/resource_spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ describe('httpResource', () => {
209209
withCredentials: true,
210210
keepalive: true,
211211
transferCache: {includeHeaders: ['Y-Tag']},
212+
timeout: 1234,
212213
}),
213214
{
214215
injector: TestBed.inject(Injector),
@@ -224,6 +225,7 @@ describe('httpResource', () => {
224225
expect(req.request.reportProgress).toEqual(true);
225226
expect(req.request.keepalive).toBe(true);
226227
expect(req.request.transferCache).toEqual({includeHeaders: ['Y-Tag']});
228+
expect(req.request.timeout).toBe(1234);
227229
});
228230

229231
it('should allow mapping data to an arbitrary type', async () => {

0 commit comments

Comments
 (0)
0