From e7e9163625670d750540deaa9764b6a1ac51c6ab Mon Sep 17 00:00:00 2001 From: Felix Palta Date: Sun, 4 Dec 2016 21:33:54 +0300 Subject: [PATCH] Encode HA2() string parameters 'method', 'uri' and 'H(entityBody)' This fixes error 500, when httpbin is run with python3 and digest-auth is attempted with qop='auth-int'. --- httpbin/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 5d59b2d..560ce13 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -292,9 +292,10 @@ def HA2(credentails, request, algorithm): for k in 'method', 'uri', 'body': if k not in request: raise ValueError("%s required" % k) - return H("%s:%s:%s" % (request['method'], - request['uri'], - H(request['body'], algorithm)), algorithm) + A2 = b":".join([request['method'].encode('utf-8'), + request['uri'].encode('utf-8'), + H(request['body'], algorithm).encode('utf-8')]) + return H(A2, algorithm) raise ValueError