Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
- [Elena Lape](https://github.com/elenalape)
- [Rohit Sehgal](https://github.com/r0hi7)
- [Bartłomiej Jacak](https://github.com/bartekjacak)
- [POTHIHAI SELVAN S P](https://github.com/po-nuvai)
7 changes: 7 additions & 0 deletions httpie/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def collect_messages(
)

response_count += 1

# Yield historical responses (e.g., 401 from digest auth) with --all
# See: https://github.com/httpie/cli/issues/1603
if args.all and response.history:
for historical_response in response.history:
yield historical_response

if response.next:
if args.max_redirects and response_count == args.max_redirects:
raise requests.TooManyRedirects
Expand Down
21 changes: 21 additions & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,24 @@ def test_ignore_netrc_null_auth():
env=MockEnvironment(),
)
assert isinstance(args.auth, ExplicitNullAuth)


def test_digest_auth_with_all_shows_401(httpbin_both):
"""
Test that --all flag shows the intermediate 401 response
when using digest authentication.

See: https://github.com/httpie/cli/issues/1603
"""
r = http(
'--all',
'--auth-type=digest',
'--auth=user:password',
'GET',
httpbin_both.url + '/digest-auth/auth/user/password'
)
# Should contain both the 401 and the 200 responses
assert '401 UNAUTHORIZED' in r or '401 Unauthorized' in r
assert HTTP_OK in r
# Verify the authenticated response body is present
assert '"authenticated": true' in r
Loading