How to use the httpie.cli.parser.parse_args function in httpie

To help you get started, we’ve selected a few httpie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand_with_path(self):
        args = parser.parse_args(args=[':/path'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost/path')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_dont_expand_shorthand_ipv6_as_shorthand(self):
        args = parser.parse_args(args=['::1'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://::1')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand(self):
        args = parser.parse_args(args=[':'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand_with_port_and_path(self):
        args = parser.parse_args(args=[':3000/path'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost:3000/path')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand_with_port_and_slash(self):
        args = parser.parse_args(args=[':3000/'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost:3000/')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand_with_port(self):
        args = parser.parse_args(args=[':3000'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost:3000')
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_dont_expand_full_ipv6_as_shorthand(self):
        args = parser.parse_args(
            args=['0000:0000:0000:0000:0000:0000:0000:0001'],
            env=TestEnvironment()
        )

        self.assertEqual(
            args.url,
            'http://0000:0000:0000:0000:0000:0000:0000:0001'
        )
github jakubroztocil / httpie / tests / tests.py View on Github external
def test_expand_localhost_shorthand_with_slash(self):
        args = parser.parse_args(args=[':/'], env=TestEnvironment())

        self.assertEqual(args.url, 'http://localhost/')
github mblayman / httpony / httpony / application.py View on Github external
def make_app():
    """Make a WSGI app that has all the HTTPie pieces baked in."""
    env = Environment()
    # STDIN is ignored because HTTPony runs a server that doesn't care.
    # Additionally, it is needed or else pytest blows up.
    args = parser.parse_args(args=["/", "--ignore-stdin"], env=env)
    args.output_options = "HB"  # Output only requests.
    server = "HTTPony/{0}".format(__version__)

    def application(environ, start_response):
        # The WSGI server puts content length and type in the environment
        # even when not provided with the request. Drop them if they are empty.
        if environ.get("CONTENT_LENGTH") == "":
            del environ["CONTENT_LENGTH"]
        if environ.get("CONTENT_TYPE") == "":
            del environ["CONTENT_TYPE"]

        wrequest = WerkzeugRequest(environ)
        data = wrequest.get_data()
        request = Request(
            method=wrequest.method,
            url=wrequest.url,