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

feat: add rawHeaders to IncomingMessage #31853

Merged
merged 7 commits into from Jan 24, 2022

Conversation

MRayermannMSFT
Copy link
Contributor

@MRayermannMSFT MRayermannMSFT commented Nov 15, 2021

Description of Change

The goal of this change is to add a rawHeaders to IncomingMessage, similar to how Node's http.IncomingMessage has a rawHeaders. Related to #31531. (Note: link to Node docs may not scroll to the right spot)

I am initially opening this PR as a draft in order to get review and approval.

cc @electron/wg-api

Checklist

Release Notes

Notes: Added rawHeaders to IncomingMessage.

@welcome
Copy link

welcome bot commented Nov 15, 2021

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Nov 15, 2021
@MRayermannMSFT
Copy link
Contributor Author

@ckerr , FYI, I attempted to tag @electron/wg-api as suggested but I think I'm not able to do so since I'm not on the electron team. Feel free to edit my description with a working tag, or just as a comment. Thanks!

@MRayermannMSFT
Copy link
Contributor Author

MRayermannMSFT commented Nov 17, 2021

@codebytere @ckerr I'm digging into the implementation for this and I think I'm at a crossroads for how to go about this. I'd like to solicit y'all's feedback before choosing an option.

It looks like the headers are getting lowercased on the C++ side of things:
image

Which means that the "rawHeaders" being sent in SimpleURLLoaderWrapper::OnResponseStarted and received in net.ts aren't really the raw headers. So I think there's two options here:

  1. Keep doing the lowercasing in C++, have SimpleURLLoaderWrapper::OnResponseStarted send those as "headers", and send actual raw headers in "rawHeaders".
  2. Stop doing lowercasing in C++, have SimpleURLLoaderWrapper::OnResponseStarted send actual raw headers in "rawHeaders", and do lowercasing in net.ts.

Personally I'm partial to option 2 since net.ts/IncomingMessage is already doing some processing of what it thinks are the raw headers. Option 1 would also result in the size of the "response-started" event increasing by what would be basically duplicate data. But perhaps there's a good reason the lowercasing is being in C++? Let me know what y'all think.

@MRayermannMSFT
Copy link
Contributor Author

MRayermannMSFT commented Nov 24, 2021

Turns out net_converter.cc is not where the lowercasing is being done. I'll share more about what I found once I have pushed some changes. Also, I am going to go with option 2.

@MRayermannMSFT
Copy link
Contributor Author

So turns out the lowercasing was being done in electron_api_url_loader.cc. The converter in net_converter.cc seems to potentially be dead code, but I don't know enough to say for sure.

@MRayermannMSFT
Copy link
Contributor Author

I think this is now ready for review? Only thing left it seems is to update typings for IncomingMessage which I'm not 100% sure on how to do. Am willing to do it of course assuming instructions can be shared. Thanks!

@MRayermannMSFT MRayermannMSFT marked this pull request as ready for review November 30, 2021 01:29
@MRayermannMSFT
Copy link
Contributor Author

@codebytere @ckerr any tips on how to get the electron.d.ts updated so my CI/CD builds can pass?

@zcbenz
Copy link
Member

zcbenz commented Dec 8, 2021

Just a notice that this organization won't have much activity this month, so review might have to wait until next month.

@MRayermannMSFT
Copy link
Contributor Author

@zcbenz thanks for letting me know. Happy holidays to you and all the other maintainers!

Copy link
Contributor

@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.

@MRayermannMSFT the typings get automatically generated from the documentation. I think the typing didn't get generated properly because the markdown needed an additional #.

docs/api/incoming-message.md Outdated Show resolved Hide resolved
@jkleinsc jkleinsc added no-backport semver/minor backwards-compatible functionality labels Jan 18, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 18, 2022
Copy link
Contributor

@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.

API LGTM

@nornagon
Copy link
Member

API LGTM

@jkleinsc jkleinsc merged commit d26d337 into electron:main Jan 24, 2022
@welcome
Copy link

welcome bot commented Jan 24, 2022

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link

release-clerk bot commented Jan 24, 2022

Release Notes Persisted

Added rawHeaders to IncomingMessage.

t57ser pushed a commit to t57ser/electron that referenced this pull request Jan 25, 2022
* Add response.rawHeaders to docs for IncomingMessage

* Remove trailing spaces

* Implement raw headers, add tests

* Fix lint issues

* Add example from NodeJS docs

* Fix lint issue in doc example

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

Successfully merging this pull request may close these issues.

None yet

6 participants