From 3c40fab03b0b9da315b98e04a35da8aab6cae534 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sat, 29 Nov 2014 00:03:29 -0800 Subject: [PATCH] GH-162: No 500 w/ better handle missing dict keys --- httpbin/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index b2264d3..89bef12 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -297,7 +297,7 @@ def response(credentails, password, request): if credentails.get('qop') is None: response = H(b":".join([ HA1_value.encode('utf-8'), - credentails.get('nonce').encode('utf-8'), + credentails.get('nonce', '').encode('utf-8'), HA2_value.encode('utf-8') ])) elif credentails.get('qop') == 'auth' or credentails.get('qop') == 'auth-int': @@ -326,6 +326,6 @@ def check_digest_auth(user, passwd): response_hash = response(credentails, passwd, dict(uri=request.path, body=request.data, method=request.method)) - if credentails['response'] == response_hash: + if credentails.get('response') == response_hash: return True return False