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.73k stars 3.68k forks source link

Digest authentication with qop=auth-int fails "TypeError: expected string or bytes-like object" #1446

Open hickford opened 1 year ago

hickford commented 1 year ago
> http -A digest -a username:password pie.dev/digest-auth/auth-int/username/password

http: error: TypeError: expected string or bytes-like object

See https://pie.dev/#/Auth/get_digest_auth__qop___user___passwd_ for more about qop

Debug output

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


> http --debug -A digest -a username:password pie.dev/digest-auth/auth-int/username/password
HTTPie 3.2.1
Requests 2.26.0
Pygments 2.7.1
Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110]
/usr/bin/python3
Linux 5.10.142-19739-g5899aa8f604c

<Environment {'apply_warnings_filter': <function Environment.apply_warnings_filter at 0x7a2958066700>,
 'args': Namespace(),
 'as_silent': <function Environment.as_silent at 0x7a29580665e0>,
 'colors': 256,
 'config': {'default_options': []},
 'config_dir': PosixPath('/home/matt/.config/httpie'),
 'devnull': <property object at 0x7a29580d0b80>,
 'is_windows': False,
 'log_error': <function Environment.log_error at 0x7a2958066670>,
 'program_name': 'http',
 'quiet': 0,
 'rich_console': <functools.cached_property object at 0x7a2958130d30>,
 'rich_error_console': <functools.cached_property object at 0x7a29580c7f10>,
 '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'>]}>

>>> requests.request(**{'auth': <requests.auth.HTTPDigestAuth object at 0x7a2957e9e190>,
 'data': RequestJSONDataDict(),
 'headers': <HTTPHeadersDict('User-Agent': b'HTTPie/3.2.1')>,
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x7a2957c7bac0>,
 'url': 'http://pie.dev/digest-auth/auth-int/username/password'})

http: error: TypeError: expected string or bytes-like object

Traceback (most recent call last):
  File "/home/matt/.local/bin/http", line 8, in <module>
    sys.exit(main())
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/__main__.py", line 9, in main
    exit_status = main()
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/core.py", line 162, in main
    return raw_main(
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/core.py", line 140, in raw_main
    handle_generic_error(e)
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/core.py", line 100, in raw_main
    exit_status = main_program(
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/core.py", line 213, in program
    for message in messages:
  File "/home/matt/.local/lib/python3.9/site-packages/httpie/client.py", line 111, in collect_messages
    response = requests_session.send(
  File "/home/matt/.local/lib/python3.9/site-packages/requests/sessions.py", line 662, in send
    r = dispatch_hook('response', hooks, r, **kwargs)
  File "/home/matt/.local/lib/python3.9/site-packages/requests/hooks.py", line 31, in dispatch_hook
    _hook_data = hook(hook_data, **kwargs)
  File "/home/matt/.local/lib/python3.9/site-packages/requests/auth.py", line 269, in handle_401
    _r = r.connection.send(prep, **kwargs)
  File "/home/matt/.local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/home/matt/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/home/matt/.local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/home/matt/.local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1296, in _send_request
    self.putheader(hdr, value)
  File "/home/matt/.local/lib/python3.9/site-packages/urllib3/connection.py", line 224, in putheader
    _HTTPConnection.putheader(self, header, *values)
  File "/usr/lib/python3.9/http/client.py", line 1232, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object```