Fix UnboundLocalError in post_urlencoded_get_json (#4460)

This could cause exceptions if the id server returned 4xx responses.
pull/14/head
Richard van der Hoff 6 years ago committed by GitHub
parent 10b89d5c2e
commit f4697b5ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      changelog.d/4460.bugfix
  2. 5
      synapse/http/client.py

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

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

Loading…
Cancel
Save