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

fix: Don't ignore the referer header in net.request #23386

Merged
merged 1 commit into from
May 20, 2020

Conversation

zeeker999
Copy link
Contributor

@zeeker999 zeeker999 commented May 2, 2020

Description of Change

Don't ignore the referrer header for a request, fixes #22411 #23102.

@zcbenz @MarshallOfSound

Checklist

Release Notes

Notes: Don't ignore the referrer header in net.request

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label May 2, 2020
@zeeker999 zeeker999 force-pushed the net-referrer-master branch from a240622 to 7b488f6 Compare May 2, 2020 15:00
@zeeker999 zeeker999 changed the title feat: Add an referrer option to net.request feat: Add a referrer option to net.request May 2, 2020
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label May 3, 2020
@zcbenz zcbenz requested a review from a team May 11, 2020 05:42
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for this! Would you mind adding a test in spec-main/api-net-spec.ts? Thanks!

@zeeker999 zeeker999 force-pushed the net-referrer-master branch from 7b488f6 to 6543833 Compare May 11, 2020 23:39
@zeeker999
Copy link
Contributor Author

zeeker999 commented May 11, 2020

Done. Could please review my changes again.

@zeeker999 zeeker999 requested a review from nornagon May 12, 2020 01:27
@zeeker999
Copy link
Contributor Author

@nornagon @zcbenz any comment for my latest change?

@@ -352,6 +352,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
request->force_ignore_site_for_cookies = true;
opts.Get("method", &request->method);
opts.Get("url", &request->url);
opts.Get("referrer", &request->referrer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this has to be a new option and we can't just read it off the headers object if it's defined? That would make it easier to use I think / be more expected that the header just works ™️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En, this way works too and less burden for user, but the current approach matches the window.fetch() better and even better if we'll introduce the referrer policy later. I don't have opinion which one is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably go with what @MarshallOfSound said and read this out of the headers option.

This API is designed to be similar to the NodeJS http API (though it doesn't match it in every respect). In the NodeJS API, setting the Referer header is done through the headers object (or setHeader), so it would be more consistent with NodeJS for us to respect that here. Additionally, the two linked bugs in the PR description show two examples of how people expect the API to work, which is similarly to the NodeJS API. I think we can avoid confusion by matching NodeJS here.

Copy link
Contributor Author

@zeeker999 zeeker999 May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I just pushed the branch forcely and changed the code to read referrer url from headers instead.

@zeeker999 zeeker999 force-pushed the net-referrer-master branch from 6543833 to 7b3e418 Compare May 19, 2020 04:44
@zeeker999 zeeker999 changed the title feat: Add a referrer option to net.request feat: Don't ignore the referrer header in net.request May 19, 2020
@zeeker999 zeeker999 force-pushed the net-referrer-master branch from 7b3e418 to 528d622 Compare May 19, 2020 05:08
@zeeker999 zeeker999 changed the title feat: Don't ignore the referrer header in net.request feat: Don't ignore the referer header in net.request May 19, 2020
Copy link
Member

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just need to remove the unneeded ts change

typings/internal-ambient.d.ts Show resolved Hide resolved
@zeeker999 zeeker999 force-pushed the net-referrer-master branch from 528d622 to 1ac1779 Compare May 19, 2020 23:06
@0xdeadbae
Copy link

0xdeadbae commented May 20, 2020

I have the same issue on Windows 1909. Electron 8.2.5.

Does this fix also solve the issue for Windows user?

@zeeker999
Copy link
Contributor Author

I have the same issue on Windows 1909. Electron 8.2.5.

Does this fix also solve the issue for Windows user?

Yes, this pull request fixes the issue for all platforms.

@zeeker999 zeeker999 force-pushed the net-referrer-master branch from 1ac1779 to 1924398 Compare May 20, 2020 01:48
@zeeker999 zeeker999 changed the title feat: Don't ignore the referer header in net.request fix: Don't ignore the referer header in net.request May 20, 2020
@jkleinsc jkleinsc merged commit 9d851b8 into electron:master May 20, 2020
@release-clerk
Copy link

release-clerk bot commented May 20, 2020

Release Notes Persisted

Don't ignore the referrer header in net.request

@trop
Copy link
Contributor

trop bot commented May 20, 2020

I was unable to backport this PR to "7-3-x" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented May 20, 2020

I was unable to backport this PR to "8-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented May 20, 2020

I was unable to backport this PR to "9-x-y" cleanly;
you will need to perform this backport manually.

@nornagon
Copy link
Member

welp

@zeeker999
Copy link
Contributor Author

zeeker999 commented May 20, 2020

Should we backport the 7e841ce to stable branches first? If we don't want backport it, I think I have to backport this pull manually.

@nornagon
Copy link
Member

I don't think we should backport 7e841ce to older branches, please go ahead and create manual backports.

(there's no need to backport to 7.x since this was only an issue since the 8.x branch)

@zeeker999
Copy link
Contributor Author

Ok. I'm going to backport this manually.

@trop
Copy link
Contributor

trop bot commented May 20, 2020

@LuoJinghua has manually backported this PR to "9-x-y", please check out #23685

@trop
Copy link
Contributor

trop bot commented May 20, 2020

@LuoJinghua has manually backported this PR to "master", please check out #23686

@trop
Copy link
Contributor

trop bot commented May 20, 2020

@LuoJinghua has manually backported this PR to "8-x-y", please check out #23688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cant't set referer header when using net.request
6 participants