Skip to content
Closed
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
2 changes: 2 additions & 0 deletions src/requests/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def sha512_utf8(x):
p_parsed = urlparse(url)
#: path is request-uri defined in RFC 2616 which should not be empty
path = p_parsed.path or "/"
if p_parsed.params:
path += f";{p_parsed.params}"
if p_parsed.query:
path += f"?{p_parsed.query}"

Expand Down
23 changes: 23 additions & 0 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,29 @@ def test_DIGESTAUTH_QUOTES_QOP_VALUE(self, httpbin):
r = requests.get(url, auth=auth)
assert '"auth"' in r.request.headers["Authorization"]

def test_DIGESTAUTH_PRESERVES_SEMICOLONS_IN_URI_PATH(self):
auth = HTTPDigestAuth("user", "pass")
auth.init_per_thread_state()
auth._thread_local.chal = {
"realm": "realm",
"nonce": "nonce",
"qop": "auth",
}

header = auth.build_digest_header(
"PUT",
(
"https://example.com/ws/2/collection/test/releases/"
"7dc2cfbd;38347564?fmt=json&client=manual-python-requests-test"
),
)

assert (
'uri="/ws/2/collection/test/releases/'
'7dc2cfbd;38347564?fmt=json&client=manual-python-requests-test"'
in header
)

def test_POSTBIN_GET_POST_FILES(self, httpbin):
url = httpbin("post")
requests.post(url).raise_for_status()
Expand Down