Add support for project-local config directories (.httpie/config.json)#1906
Open
kova1max wants to merge 1 commit into
Open
Add support for project-local config directories (.httpie/config.json)#1906kova1max wants to merge 1 commit into
kova1max wants to merge 1 commit into
Conversation
Look for a `.httpie` directory containing `config.json` in the current working directory and its parents (nearest match wins), before falling back to the global config location. An explicitly set `$HTTPIE_CONFIG_DIR` still takes precedence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1229.
This PR adds discovery of a project-local config directory: a
.httpiedirectory containingconfig.json, looked up from the current working directory upwards (nearest match wins) β the same discovery convention as.gitor.npmrc.Motivation
The global config applies to every invocation, which pollutes unrelated requests (see #1229).
$HTTPIE_CONFIG_DIRsolves this only partially β it has to be exported in every shell, which is cumbersome and doesn't work well in teams. A per-project config that is simply picked up when working inside the project directory tree solves both #1229 and, indirectly, the per-host use case of #809 without thelocalhostcollision problem described in #1229.Design decisions
.httpie/) rather than a single.httpiercfile, so the existingConfigmachinery works unchanged and sessions/plugins get project scoping for free.config.jsonmust exist inside β a bare.httpiedirectory is ignored, so stray directories can't silently hijack configuration (and the legacy~/.httpiebehavior is preserved unchanged).$HTTPIE_CONFIG_DIRalways wins, keeping the current escape hatch.Resolution order:
$HTTPIE_CONFIG_DIRβ nearest.httpie/config.jsonupwards from cwd β platform defaults (unchanged).Security consideration
Auto-loading config from a directory tree means a cloned repository can inject
default_options(e.g.--proxy,--verify=no). This mirrors the long-standing behavior of npm's.npmrc. If you'd prefer, discovery could be gated behind an opt-in global setting β happy to adjust.Checklist
tests/test_config.py)test_encoding.pybig5 failures reproduce on cleanmasterand are unrelated)docs/README.md)