forked from extern/httpie-cli
check --ssl-cert and --ssl-key to be files
This commit is contained in:
parent
14583a2efa
commit
b9d7220b10
@ -19,6 +19,7 @@ from .input import (Parser, AuthCredentialsArgType, KeyValueArgType,
|
||||
OUT_REQ_HEAD, OUT_REQ_BODY, OUT_RESP_HEAD,
|
||||
OUT_RESP_BODY, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT,
|
||||
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, SessionNameValidator)
|
||||
from .utils import existing_file
|
||||
|
||||
|
||||
class HTTPieHelpFormatter(RawDescriptionHelpFormatter):
|
||||
@ -468,6 +469,7 @@ network.add_argument(
|
||||
network.add_argument(
|
||||
'--ssl-cert',
|
||||
default=None,
|
||||
type=existing_file,
|
||||
help="""
|
||||
You can specify a local cert to use as client side SSL certificate.
|
||||
This file may either contain both private key and certificate or you may
|
||||
@ -479,6 +481,7 @@ network.add_argument(
|
||||
network.add_argument(
|
||||
'--ssl-key',
|
||||
default=None,
|
||||
type=existing_file,
|
||||
help="""
|
||||
The private key to use with SSL. Only needed if --ssl-cert is given and the
|
||||
certificate file does not contain the private key.
|
||||
|
@ -1,4 +1,5 @@
|
||||
from __future__ import division
|
||||
import argparse
|
||||
|
||||
|
||||
def humanize_bytes(n, precision=2):
|
||||
@ -44,3 +45,12 @@ def humanize_bytes(n, precision=2):
|
||||
break
|
||||
|
||||
return '%.*f %s' % (precision, n / factor, suffix)
|
||||
|
||||
|
||||
def existing_file(filename):
|
||||
try:
|
||||
open(filename, 'rb')
|
||||
except IOError as ex:
|
||||
raise argparse.ArgumentTypeError(
|
||||
'%s: %s' % (filename, ex.args[1]))
|
||||
return filename
|
||||
|
Loading…
Reference in New Issue
Block a user