File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ def sha512_utf8(x):
183183 p_parsed = urlparse (url )
184184 #: path is request-uri defined in RFC 2616 which should not be empty
185185 path = p_parsed .path or "/"
186+ if p_parsed .params :
187+ path += f";{ p_parsed .params } "
186188 if p_parsed .query :
187189 path += f"?{ p_parsed .query } "
188190
Original file line number Diff line number Diff line change 1+ """Tests for Digest Auth URI handling (issue #6990)."""
2+
3+ import requests
4+ from requests .auth import HTTPDigestAuth
5+
6+
7+ def test_digest_auth_uri_includes_semicolon_params ():
8+ """Digest auth URI must include semicolon path parameters (issue #6990)."""
9+ auth = HTTPDigestAuth ("user" , "pass" )
10+ auth ._thread_local .chal = {
11+ "realm" : "testrealm" ,
12+ "nonce" : "testnonce" ,
13+ "qop" : "auth" ,
14+ }
15+ auth ._thread_local .last_nonce = ""
16+ auth ._thread_local .nonce_count = 0
17+
18+ url = "http://example.com/path;jsessionid=abc123?q=1"
19+ header = auth .build_digest_header ("GET" , url )
20+
21+ assert 'uri="/path;jsessionid=abc123?q=1"' in header
22+
23+
24+ def test_digest_auth_uri_without_semicolon_params ():
25+ """Digest auth URI is unchanged for URLs without semicolon path params."""
26+ auth = HTTPDigestAuth ("user" , "pass" )
27+ auth ._thread_local .chal = {
28+ "realm" : "testrealm" ,
29+ "nonce" : "testnonce" ,
30+ "qop" : "auth" ,
31+ }
32+ auth ._thread_local .last_nonce = ""
33+ auth ._thread_local .nonce_count = 0
34+
35+ url = "http://example.com/path?q=1"
36+ header = auth .build_digest_header ("GET" , url )
37+
38+ assert 'uri="/path?q=1"' in header
You can’t perform that action at this time.
0 commit comments