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

TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked' #14

Open
albertodonato opened this issue Jun 15, 2023 · 2 comments

Comments

@albertodonato
Copy link

When trying to use httpie with a unix socket, I'm getting the mentioned error with the following traceback:

$  httpie/bin/http --debug http+unix://%2Fsome%2Fsocket/path
HTTPie 3.2.2
Requests 2.31.0
Pygments 2.15.1
Python 3.11.2 (main, May 30 2023, 17:45:26) [GCC 12.2.0]
/home/ack/Desktop/httpie/bin/python3
Linux 6.2.0-20-generic

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7ff70d8b0680>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x7ff70d8b0540>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/ack/.config/httpie'),
 'devnull': <property object at 0x7ff70d895ee0>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7ff70d8b05e0>,
 'program_name': 'http',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x7ff70d89eed0>,
 'rich_error_console': <functools.cached_property object at 0x7ff70d89f5d0>,
 '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': [<class 'httpie_unixsocket.UnixSocketTransportPlugin'>],
 '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'>]}>

>>> requests.request(**{'auth': None,
 'data': RequestJSONDataDict(),
 'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.2.2')>,
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x7ff70d39f840>,
 'url': 'http+unix://%2Fsome%2Fsocket/path'})


http: error: TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'


Traceback (most recent call last):
  File "/home/ack/Desktop/httpie/bin/http", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/__main__.py", line 9, in main
    exit_status = main()
                  ^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 162, in main
    return raw_main(
           ^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 140, in raw_main
    handle_generic_error(e)
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 100, in raw_main
    exit_status = main_program(
                  ^^^^^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/core.py", line 213, in program
    for message in messages:
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/httpie/client.py", line 113, in collect_messages
    response = requests_session.send(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/home/ack/Desktop/httpie/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

These are the versions I'm using:

$  httpie/bin/pip freeze
certifi==2023.5.7
charset-normalizer==3.1.0
defusedxml==0.7.1
httpie==3.2.2
httpie-unixsocket==0.0.0
idna==3.4
markdown-it-py==3.0.0
mdurl==0.1.2
multidict==6.0.4
Pygments==2.15.1
PySocks==1.7.1
requests==2.31.0
requests-toolbelt==1.0.0
requests-unixsocket==0.3.0
rich==13.4.2
urllib3==2.0.3
@tsunghanliu
Copy link

While I'm investigating this issue, I found that the patch of msabramo/requests-unixsocket#69 also helps on this issue.
Once the PR got merged, this issue should be resolved as well

@notpushkin
Copy link

Looks like that PR isn't getting merged anytime soon. I've installed the fork proposed there (if you use pipx, pipx inject httipe requests-unixsocket2 should do the trick) and it seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants