Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions goldens/public-api/common/http/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2784,12 +2784,14 @@ export interface HttpResourceRequest {
context?: HttpContext;
credentials?: RequestCredentials | (string & {});
headers?: HttpHeaders | Record<string, string | ReadonlyArray<string>>;
integrity?: string;
keepalive?: boolean;
method?: string;
mode?: RequestMode | (string & {});
params?: HttpParams | Record<string, string | number | boolean | ReadonlyArray<string | number | boolean>>;
priority?: RequestPriority | (string & {});
redirect?: RequestRedirect | (string & {});
referrer?: string;
reportProgress?: boolean;
timeout?: number;
transferCache?: {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/http/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ function normalizeRequest(
context: unwrappedRequest.context,
transferCache: unwrappedRequest.transferCache,
credentials: unwrappedRequest.credentials as RequestCredentials,
referrer: unwrappedRequest.referrer,
integrity: unwrappedRequest.integrity,
timeout: unwrappedRequest.timeout,
},
);
Expand Down
13 changes: 13 additions & 0 deletions packages/common/http/src/resource_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ export interface HttpResourceRequest {
*/
redirect?: RequestRedirect | (string & {});

/**
* The referrer of the request, which can be used to indicate the origin of the request.
* This is useful for security and analytics purposes.
* Value is a same-origin URL, "about:client", or the empty string, to set request's referrer.
*/
referrer?: string;

/**
* The integrity metadata of the request, which can be used to ensure the request is made with the expected content.
* A cryptographic hash of the resource to be fetched by request
*/
integrity?: string;

/**
* Configures the server-side rendering transfer cache for this request.
*
Expand Down
4 changes: 4 additions & 0 deletions packages/common/http/test/resource_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ describe('httpResource', () => {
mode: 'cors',
redirect: 'follow',
credentials: 'include',
integrity: 'sha256-abc123',
referrer: 'https://example.com',
}),
{injector: TestBed.inject(Injector)},
);
Expand All @@ -126,6 +128,8 @@ describe('httpResource', () => {
expect(req.request.mode).toBe('cors');
expect(req.request.redirect).toBe('follow');
expect(req.request.credentials).toBe('include');
expect(req.request.integrity).toBe('sha256-abc123');
expect(req.request.referrer).toBe('https://example.com');

req.flush([]);

Expand Down