Skip to content

Commit

Permalink
Requested changes for pypa#8078
Browse files Browse the repository at this point in the history
- Condense changelog with reference to discussion pypa#8042
- Change warning to hard error with reference to pypa#8042 on multiple index URLs
- Change critical to warning on header parsing errors
  • Loading branch information
Alexander Mancevice authored and amancevice committed Jul 16, 2020
1 parent 813db6b commit abb9ab8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
16 changes: 2 additions & 14 deletions news/8042.feature
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
Add CLI options for enhancing requests with HTTP headers
Add CLI option -H / --header for enhancing requests with HTTP headers.

-H, --header <key:val> HTTP header to include in all requests. This option
can be used multiple times. Conflicts with
--extra-index-url.

Example:

```
pip install \
--index-url http://pypi.index/simple/ \
--trusted-host pypi.index \
-H 'X-Spam: ~*~ SPAM ~*~' \
requests
```
See https://github.com/pypa/pip/issues/8042 for discussion.
8 changes: 4 additions & 4 deletions src/pip/_internal/cli/req_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def _get_headers(cls, options):
# Refuse to set headers when multiple index URLs are set
index_urls = cls._get_index_urls(options)
if index_urls and len(index_urls) > 1:
logger.warning(
raise CommandError(
'Refusing to set -H / --header option(s) because multiple '
'index URLs are configured.',
'index URLs are configured. '
'See https://github.com/pypa/pip/issues/8042 for more info.',
)
return None

# Parse header inputs into dict
headers = {}
Expand All @@ -102,7 +102,7 @@ def _get_headers(cls, options):
key, val = match.groups()
headers[key] = val
else:
logger.critical('Could not parse header {!r}'.format(header))
logger.warning('Could not parse header {!r}'.format(header))
return headers or None

def get_default_session(self, options):
Expand Down

0 comments on commit abb9ab8

Please sign in to comment.