mirror of
https://github.com/httpie/cli.git
synced 2024-11-28 08:38:44 +02:00
Add support for Digest authentication
This commit is contained in:
parent
1c5fd18465
commit
153663cb92
@ -133,6 +133,12 @@ def main(args=None,
|
|||||||
|
|
||||||
# Fire the request.
|
# Fire the request.
|
||||||
try:
|
try:
|
||||||
|
credentials = None
|
||||||
|
if args.auth and args.digest:
|
||||||
|
credentials = requests.auth.HTTPDigestAuth(args.auth.key, args.auth.value)
|
||||||
|
elif args.auth:
|
||||||
|
credentials = requests.auth.HTTPBasicAuth(args.auth.key, args.auth.value)
|
||||||
|
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
method=args.method.lower(),
|
method=args.method.lower(),
|
||||||
url=args.url if '://' in args.url else 'http://%s' % args.url,
|
url=args.url if '://' in args.url else 'http://%s' % args.url,
|
||||||
@ -140,7 +146,7 @@ def main(args=None,
|
|||||||
data=data,
|
data=data,
|
||||||
verify=True if args.verify == 'yes' else args.verify,
|
verify=True if args.verify == 'yes' else args.verify,
|
||||||
timeout=args.timeout,
|
timeout=args.timeout,
|
||||||
auth=(args.auth.key, args.auth.value) if args.auth else None,
|
auth=credentials,
|
||||||
proxies=dict((p.key, p.value) for p in args.proxy),
|
proxies=dict((p.key, p.value) for p in args.proxy),
|
||||||
files=files,
|
files=files,
|
||||||
allow_redirects=args.allow_redirects,
|
allow_redirects=args.allow_redirects,
|
||||||
|
@ -215,6 +215,11 @@ parser.add_argument(
|
|||||||
'--auth', '-a', help='username:password',
|
'--auth', '-a', help='username:password',
|
||||||
type=KeyValueType(SEP_COMMON)
|
type=KeyValueType(SEP_COMMON)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--digest', '-d', action='store_true', help=_('Use Digest authentication')
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--verify',
|
'--verify',
|
||||||
help=_('''
|
help=_('''
|
||||||
|
Loading…
Reference in New Issue
Block a user