httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.74k stars 3.68k forks source link

Cannot set content-type #1443

Closed FlorianTolk closed 1 year ago

FlorianTolk commented 1 year ago

Checklist


Minimal reproduction code and steps

Trying to connect to an API on localhost:66398, API is running and can be hit with curl. Using ubuntu 20.04, and httpie version 3.2.1.

  1. httpie command (With redactions) http POST http://localhost:63398/api/v1/course -A bearer -a <BearerToken> Content-type: application/zip < Course.zip

Current result

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

error:
    unrecognized arguments: Content-type:application/zip

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

Expected result

A 200 response from the server …


Debug output

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

$ http --debug POST http://localhost:63398/api/v1/course -A bearer -a <token> Content-Type:application/zip < Course.zip
HTTPie 3.2.1
Requests 2.27.1
Pygments 2.12.0
Python 3.9.12 (main, Apr 16 2022, 19:31:36) 
[GCC 7.5.0]
/usr/bin/http
Linux 5.15.0-46-generic

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7f54694898b0>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x7f5469489790>,
 'colors': 256,
 'config': {'__meta__': {'about': 'HTTPie configuration file',
                         'help': 'https://httpie.org/doc#config',
                         'httpie': '1.0.3'},
            'default_options': []},
 'config_dir': PosixPath('/home/ftolk/.httpie'),
 'devnull': <property object at 0x7f5469481db0>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7f5469489820>,
 'program_name': 'http',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x7f5469473490>,
 'rich_error_console': <functools.cached_property object at 0x7f5469473640>,
 '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': False,
 '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: Content-Type:application/zip

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

Additional information, screenshots, or code examples

I have also tried multiple capitalizations of the Content-Type header, all with the same results. …