Skip to content

Commit

Permalink
Refactored @mmb's fix to --verify; updated docs.
Browse files Browse the repository at this point in the history
Closes #32.
  • Loading branch information
jkbrzt committed Apr 11, 2012
1 parent 71d21d1 commit c6c1489
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 12 additions & 4 deletions README.rst
Expand Up @@ -103,6 +103,13 @@ Flags
^^^^^
Most of the flags mirror the arguments understood by ``requests.request``. See ``http -h`` for more details::

usage: http [-h] [--version] [--json | --form] [--traceback]
[--pretty | --ugly]
[--print OUTPUT_OPTIONS | --verbose | --headers | --body]
[--style STYLE] [--auth AUTH] [--verify VERIFY]
[--proxy PROXY] [--allow-redirects] [--timeout TIMEOUT]
METHOD URL [items [items ...]]

HTTPie - cURL for humans.

positional arguments:
Expand Down Expand Up @@ -147,10 +154,11 @@ Most of the flags mirror the arguments understood by ``requests.request``. See `
monokai, murphy, native, pastie, perldoc, solarized,
tango, trac, vim, vs. Defaults to solarized.
--auth AUTH, -a AUTH username:password
--verify VERIFY Set to "yes" to check the host's SSL certificate. You
can also pass the path to a CA_BUNDLE file for private
certs. You can also set the REQUESTS_CA_BUNDLE
environment variable.
--verify VERIFY Set to "no" to skip checking the host's SSL
certificate. You can also pass the path to a CA_BUNDLE
file for private certs. You can also set the
REQUESTS_CA_BUNDLE environment variable. Defaults to
"yes".
--proxy PROXY String mapping protocol to the URL of the proxy (e.g.
http:foo.bar:3128).
--allow-redirects Set this flag if full redirects are allowed (e.g. re-
Expand Down
9 changes: 1 addition & 8 deletions httpie/__main__.py
Expand Up @@ -131,21 +131,14 @@ def main(args=None,
elif not files and 'Content-Type' not in headers:
headers['Content-Type'] = TYPE_FORM

if args.verify == 'yes':
verify = True
elif args.verify == 'no':
verify = False
else:
verify = args.verify

# Fire the request.
try:
response = requests.request(
method=args.method.lower(),
url=args.url if '://' in args.url else 'http://%s' % args.url,
headers=headers,
data=data,
verify=verify,
verify={'yes': True, 'no': False}.get(args.verify, args.verify),
timeout=args.timeout,
auth=(args.auth.key, args.auth.value) if args.auth else None,
proxies=dict((p.key, p.value) for p in args.proxy),
Expand Down
5 changes: 3 additions & 2 deletions httpie/cli.py
Expand Up @@ -216,12 +216,13 @@ def _validate_output_options(self, args):
type=KeyValueType(SEP_COMMON)
)
parser.add_argument(
'--verify',
'--verify', default='yes',
help=_('''
Set to "yes" to check the host\'s SSL certificate.
Set to "no" to skip checking the host\'s SSL certificate.
You can also pass the path to a CA_BUNDLE
file for private certs. You can also set
the REQUESTS_CA_BUNDLE environment variable.
Defaults to "yes".
''')
)
parser.add_argument(
Expand Down

0 comments on commit c6c1489

Please sign in to comment.