Fix UnboundLocalError in post_urlencoded_get_json (#4460)

This could cause exceptions if the id server returned 4xx responses.
pull/4462/head
Richard van der Hoff 2019-01-24 13:38:29 +00:00 committed by GitHub
parent 10b89d5c2e
commit f4697b5ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

1
changelog.d/4460.bugfix Normal file
View File

@ -0,0 +1 @@
Fix UnboundLocalError in post_urlencoded_get_json

View File

@ -333,9 +333,10 @@ class SimpleHttpClient(object):
"POST", uri, headers=Headers(actual_headers), data=query_bytes "POST", uri, headers=Headers(actual_headers), data=query_bytes
) )
body = yield make_deferred_yieldable(readBody(response))
if 200 <= response.code < 300: if 200 <= response.code < 300:
body = yield make_deferred_yieldable(treq.json_content(response)) defer.returnValue(json.loads(body))
defer.returnValue(body)
else: else:
raise HttpResponseException(response.code, response.phrase, body) raise HttpResponseException(response.code, response.phrase, body)