cli icon indicating copy to clipboard operation
cli copied to clipboard

Using METHOD and --verify causes URL not to be recognized

Open kuba-orlik opened this issue 1 year ago • 1 comments

Checklist

  • [x] I've searched for similar issues.
  • [x] I'm using the latest version of HTTPie.

Minimal reproduction code and steps

  1. https GET --verify=no pie.dev/get

Current result

usage:
    http [METHOD] URL [REQUEST_ITEM ...]

error:
    unrecognized arguments: pie.dev/get

for more information:
    run 'http --help' or visit https://httpie.io/docs/cli

Expected result

Make the request to the URL


Debug output

Please re-run the command with --debug, then copy the entire command & output and paste both below:

$ https  --debug GET --verify=no pie.dev/get
HTTPie 3.2.3
Requests 2.32.3
Pygments 2.18.0
Python 3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522]
/usr/bin/python
Linux 6.6.42-1-lts

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7fab523e4ea0>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x7fab523e4d60>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/kuba/.config/httpie'),
 'devnull': <property object at 0x7fab523e8360>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7fab523e4e00>,
 'program_name': 'https',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x7fab527bb800>,
 'rich_error_console': <functools.cached_property object at 0x7fab5238ff50>,
 'show_displays': True,
 'stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>,
 'stderr_isatty': True,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

<PluginManager {'adapters': [],
 'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
          <class 'httpie.plugins.builtin.DigestAuthPlugin'>,
          <class 'httpie.plugins.builtin.BearerAuthPlugin'>],
 'converters': [],
 'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
                <class 'httpie.output.formatters.json.JSONFormatter'>,
                <class 'httpie.output.formatters.xml.XMLFormatter'>,
                <class 'httpie.output.formatters.colors.ColorFormatter'>]}>
usage:
    http [METHOD] URL [REQUEST_ITEM ...]

error:
    unrecognized arguments: pie.dev/get

for more information:
    run 'http --help' or visit https://httpie.io/docs/cli

kuba-orlik avatar Aug 06 '24 13:08 kuba-orlik

Not a core contributor, just another httpie user.

The following command works fine: http GET pie.dev/get --verify=no

The error you're facing might be due to the fact that httpie cli expects a URL immediately followed by METHOD. After the URL it accepts any request options(headers, form/json data fields, etc.)

>https GET pie.dev/get --verify=false
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
CF-Cache-Status: DYNAMIC
CF-RAY: 8b20b2e36b718319-SIN
Connection: keep-alive
Content-Encoding: br
Content-Type: application/json
Date: Mon, 12 Aug 2024 13:09:15 GMT
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=rnsU0VHiR4IVHLO66g0i9Cw6i31wAYVpKSpig2rjSnoTLfD%2FPOI9Wh5jmpL1zvq9S1xKes2xbDZll7BmJIbecM%2FFDJD5%2F7zLQfutsEMZ9q7zmnh6QemyNEx%2B2%2BBOJ5nlTdut%2F3qO"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Transfer-Encoding: chunked
alt-svc: h3=":443"; ma=86400
...

You don't need to specify the HTTP method manually. When you include data fields (like JSON or form data), HTTPie automatically chooses the appropriate method, such as GET or POST, based on the context.

Arpit-Khandelwal avatar Aug 12 '24 13:08 Arpit-Khandelwal