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: Support response headers in File protocol handler #16098

Merged
merged 3 commits into from Dec 19, 2018

Conversation

Projects
None yet
3 participants
@dbkr
Copy link
Contributor

commented Dec 17, 2018

Description of Change

This adds support for response headers to protocol.registerFileProtocol to match protocol.registerStreamProtocol.

My specific use case for this is to set a CSP for pages served from local content rather than HTTPS: setting the header by intercepting the request with the webRequest module doesn't work because URLRequestAsarJob doesn't call the network_delegate methods (see #16030). In any case, this seems like a more direct way of setting the header.

I've also changed how this works a little to make it more consistent (hopefully) with the other handlers (ie. convert the dict to a base::DictionaryValue and use base::DictionaryValue::GetFoo()).

Note that I've documented this in the text as the callback param in the list has filePath as a string. This could be changed so the callback taking an object is in the main docs: I'm happy to make this change.

Stakeholders: @zcbenz & @paulcbetts appear to have last made major changes here. cc @MarshallOfSound as you kindly helped on the issue I filed.

Test failures don't appear to be related to my changes: one of them is:

AssertionError: exit signal should be null, if you see this please tag @MarshallOfSound: expected 'SIGSEGV' to equal null

(so, cc @MarshallOfSound)

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes: failures appear unrelated to my changes
  • tests are changed or added
  • relevant documentation is changed or added
  • PR title follows semantic commit guidelines

Release Notes

Notes: Add response header support to protocol.registerFileProtocol to match protocol.registerStreamProtocol.

@dbkr dbkr requested review from as code owners Dec 17, 2018

@welcome

This comment has been minimized.

Copy link

commented Dec 17, 2018

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

@dbkr dbkr changed the title feat: Support response headers in File protocol handler [wip] feat: Support response headers in File protocol handler Dec 17, 2018

@dbkr dbkr changed the title [wip] feat: Support response headers in File protocol handler feat: Support response headers in File protocol handler Dec 17, 2018

@ckerr
Copy link
Member

left a comment

Premise and tests LGTM. Thanks for the patch!

Once the deprecated API use is changed I'm 👍 on this

base::DictionaryValue* headersValue = nullptr;
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(options.get());
dict->GetString("path", &file_path);

This comment has been minimized.

Copy link
@ckerr

ckerr Dec 17, 2018

Member

This introduces a minor regression of going back to deprecated API:

// DEPRECATED, use Value::FindPath(path) and Value::GetString() instead.
bool GetString(StringPiece path, std::string* out_value) const;

Could you keep the previous FindKeyOfType implementation?

This comment has been minimized.

Copy link
@dbkr

dbkr Dec 17, 2018

Author Contributor

Ah, hadn't noticed that was deprecated. Fixed!

@codebytere
Copy link
Member

left a comment

👍 following your latest changes!

@ckerr

ckerr approved these changes Dec 19, 2018

Copy link
Member

left a comment

Thanks!

@codebytere codebytere merged commit cc85946 into electron:master Dec 19, 2018

21 of 23 checks passed

ci/circleci: mas-testing-tests Your tests failed on CircleCI
Details
Artifact Comparison Changes Detected
Details
Absolute Zero
Semantic Pull Request ready to be squashed
Details
WIP Legacy commit status override — see details
Details
appveyor: win-ia32-testing-pr AppVeyor build succeeded
Details
appveyor: win-x64-testing-pr AppVeyor build succeeded
Details
ci/circleci: linux-arm-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-arm-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-arm64-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-arm64-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-checkout Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-ia32-testing-tests Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-debug Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-testing Your tests passed on CircleCI!
Details
ci/circleci: linux-x64-testing-tests Your tests passed on CircleCI!
Details
ci/circleci: mas-testing Your tests passed on CircleCI!
Details
ci/circleci: osx-testing Your tests passed on CircleCI!
Details
ci/circleci: osx-testing-tests Your tests passed on CircleCI!
Details
electron-lint Build #20181217.13 succeeded
Details
release-notes Release notes found
@release-clerk

This comment has been minimized.

Copy link

commented Dec 19, 2018

Release Notes Persisted

Add response header support to protocol.registerFileProtocol to match protocol.registerStreamProtocol.

@welcome

This comment has been minimized.

Copy link

commented Dec 19, 2018

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.