1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-28 08:38:44 +02:00

Refactored @mmb's fix to --verify; updated docs.

Closes #32.
This commit is contained in:
Jakub Roztocil 2012-04-11 12:44:02 +02:00
parent 71d21d1feb
commit c6c1489212
3 changed files with 16 additions and 14 deletions

View File

@ -103,6 +103,13 @@ Flags
^^^^^ ^^^^^
Most of the flags mirror the arguments understood by ``requests.request``. See ``http -h`` for more details:: 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. HTTPie - cURL for humans.
positional arguments: positional arguments:
@ -147,10 +154,11 @@ Most of the flags mirror the arguments understood by ``requests.request``. See `
monokai, murphy, native, pastie, perldoc, solarized, monokai, murphy, native, pastie, perldoc, solarized,
tango, trac, vim, vs. Defaults to solarized. tango, trac, vim, vs. Defaults to solarized.
--auth AUTH, -a AUTH username:password --auth AUTH, -a AUTH username:password
--verify VERIFY Set to "yes" to check the host's SSL certificate. You --verify VERIFY Set to "no" to skip checking the host's SSL
can also pass the path to a CA_BUNDLE file for private certificate. You can also pass the path to a CA_BUNDLE
certs. You can also set the REQUESTS_CA_BUNDLE file for private certs. You can also set the
environment variable. REQUESTS_CA_BUNDLE environment variable. Defaults to
"yes".
--proxy PROXY String mapping protocol to the URL of the proxy (e.g. --proxy PROXY String mapping protocol to the URL of the proxy (e.g.
http:foo.bar:3128). http:foo.bar:3128).
--allow-redirects Set this flag if full redirects are allowed (e.g. re- --allow-redirects Set this flag if full redirects are allowed (e.g. re-

View File

@ -131,13 +131,6 @@ def main(args=None,
elif not files and 'Content-Type' not in headers: elif not files and 'Content-Type' not in headers:
headers['Content-Type'] = TYPE_FORM headers['Content-Type'] = TYPE_FORM
if args.verify == 'yes':
verify = True
elif args.verify == 'no':
verify = False
else:
verify = args.verify
# Fire the request. # Fire the request.
try: try:
response = requests.request( response = requests.request(
@ -145,7 +138,7 @@ def main(args=None,
url=args.url if '://' in args.url else 'http://%s' % args.url, url=args.url if '://' in args.url else 'http://%s' % args.url,
headers=headers, headers=headers,
data=data, data=data,
verify=verify, verify={'yes': True, 'no': False}.get(args.verify, args.verify),
timeout=args.timeout, timeout=args.timeout,
auth=(args.auth.key, args.auth.value) if args.auth else None, auth=(args.auth.key, args.auth.value) if args.auth else None,
proxies=dict((p.key, p.value) for p in args.proxy), proxies=dict((p.key, p.value) for p in args.proxy),

View File

@ -216,12 +216,13 @@ parser.add_argument(
type=KeyValueType(SEP_COMMON) type=KeyValueType(SEP_COMMON)
) )
parser.add_argument( parser.add_argument(
'--verify', '--verify', default='yes',
help=_(''' 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 You can also pass the path to a CA_BUNDLE
file for private certs. You can also set file for private certs. You can also set
the REQUESTS_CA_BUNDLE environment variable. the REQUESTS_CA_BUNDLE environment variable.
Defaults to "yes".
''') ''')
) )
parser.add_argument( parser.add_argument(