From 6259b5dd3bf52ff0d008a1b19de489389e60d297 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Wed, 28 Oct 2015 15:06:04 -0700 Subject: [PATCH] Add a --default-scheme argument. --- httpie/cli.py | 10 ++++++++++ httpie/input.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/httpie/cli.py b/httpie/cli.py index 2b05a883..47ee4c54 100644 --- a/httpie/cli.py +++ b/httpie/cli.py @@ -88,6 +88,7 @@ positional.add_argument( metavar='URL', help=""" The scheme defaults to 'http://' if the URL does not include one. + (You can override this with: --default-scheme https) You can also use a shorthand for localhost @@ -558,6 +559,15 @@ troubleshooting.add_argument( """ ) +troubleshooting.add_argument( + '--default-scheme', + choices=["http", "https"], + default="http", + help=""" + Default scheme to use if not specified in the URL. + + """ +) troubleshooting.add_argument( '--debug', action='store_true', diff --git a/httpie/input.py b/httpie/input.py index da3cc525..ecddc5a4 100644 --- a/httpie/input.py +++ b/httpie/input.py @@ -137,7 +137,7 @@ class Parser(ArgumentParser): if not self.args.ignore_stdin and not env.stdin_isatty: self._body_from_file(self.env.stdin) if not URL_SCHEME_RE.match(self.args.url): - scheme = HTTP + scheme = self.args.default_scheme + "://" # See if we're using curl style shorthand for localhost (:3000/foo) shorthand = re.match(r'^:(?!:)(\d*)(/?.*)$', self.args.url)