Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
kuba-orlik opened this issue Aug 6, 2024 · 1 comment
Open
2 tasks done

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

kuba-orlik opened this issue Aug 6, 2024 · 1 comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!

Comments

@kuba-orlik
Copy link

Checklist

  • I've searched for similar issues.
  • 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 kuba-orlik added bug Something isn't working new Needs triage. Comments are welcome! labels Aug 6, 2024
@Arpit-Khandelwal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Needs triage. Comments are welcome!
Projects
None yet
Development

No branches or pull requests

2 participants