Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpRequest.clone forgets transferCache #54924

Closed
cclausen opened this issue Mar 18, 2024 · 4 comments
Closed

HttpRequest.clone forgets transferCache #54924

cclausen opened this issue Mar 18, 2024 · 4 comments
Labels
area: common/http bug good first issue An issue that is suitable for first-time contributors; often a documentation issue. help wanted An issue that is suitable for a community contributor (based on its complexity/scope). P2 The issue is important to a large percentage of users, with a workaround state: has PR
Milestone

Comments

@cclausen
Copy link

Which @angular/* package(s) are the source of the bug?

common

Is this a regression?

No

Description

When cloning the HttpRequest, like keycloak does in it's interceptor, the clone-method forgets the transferCache-property.

req.transferCache = true;
this.keycloak.addTokenToHeader(req.headers).pipe(mergeMap(headersWithBearer => {
      const kcReq = req.clone({
        headers: headersWithBearer
      });
      return next.handle(kcReq);
    }));
req.transferCache === true;
kcReq.transferCache === undefined;

The HttpRequest-constructor expects the transferCache to be set in the options-parameter, but the clone-method does not provide it.

This code should fix the problem.

`
const transferCache = update.transferCache || this.transferCache ;

// Finally, construct the new HttpRequest using the pieces from above.
return new HttpRequest(method, url, body, {
  params,
  headers,
  context,
  reportProgress,
  responseType,
  withCredentials,
 transferCache ,
});`

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.3.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: win32 x64

Angular: 17.3.0
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.0
@angular-devkit/build-angular   17.3.0
@angular-devkit/core            17.3.0
@angular-devkit/schematics      17.3.0
@schematics/angular             17.3.0
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.4

Anything else?

No response

@alan-agius4 alan-agius4 added area: common/http good first issue An issue that is suitable for first-time contributors; often a documentation issue. labels Mar 18, 2024
@ngbot ngbot bot added this to the needsTriage milestone Mar 18, 2024
@alan-agius4 alan-agius4 added bug help wanted An issue that is suitable for a community contributor (based on its complexity/scope). labels Mar 18, 2024
@alxhub alxhub added the P2 The issue is important to a large percentage of users, with a workaround label Mar 18, 2024
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 18, 2024
@sunilbaba
Copy link
Contributor

Hi All,
I want to give a try on this one.

@lazybobcat
Copy link

Hi All, I want to give a try on this one.

Tell me if you need any help with this :)

mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
@mlz11
Copy link
Contributor

mlz11 commented Mar 19, 2024

Hello 👋🏻

I have opened PR #54939 that hopefully fixes the issue 🙂

Thanks for your help reviewing it !

mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
mlz11 added a commit to mlz11/angular that referenced this issue Mar 19, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.
dylhunn pushed a commit that referenced this issue Mar 22, 2024
Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes #54924.

PR Close #54939
ilirbeqirii pushed a commit to ilirbeqirii/angular that referenced this issue Apr 6, 2024
)

Fixes a bug where HttpRequest.clone() does not include the transferCache property.

Fixes angular#54924.

PR Close angular#54939
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: common/http bug good first issue An issue that is suitable for first-time contributors; often a documentation issue. help wanted An issue that is suitable for a community contributor (based on its complexity/scope). P2 The issue is important to a large percentage of users, with a workaround state: has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants