Skip to content

Commit

Permalink
handle utf-8 in body when posting queries
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmeister committed Jun 7, 2011
1 parent 1359011 commit 88268fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions couchdb-external-hook.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def respond(res, req, key):
method = req["verb"] method = req["verb"]


if method == "POST": if method == "POST":
res.request(method, path,req.get("body"),req_headers) res.request(method, path,req.get("body").decode("utf-8"),req_headers)
else: else:
res.request(method, path, headers=req_headers) res.request(method, path, headers=req_headers)
resp = res.getresponse() resp = res.getresponse()
Expand All @@ -92,7 +92,7 @@ def respond(res, req, key):
return mkresp(resp.status, resp.read(), resp_headers) return mkresp(resp.status, resp.read(), resp_headers)


def mkresp(code, body, headers=None): def mkresp(code, body, headers=None):
ret = {"code": code, "body": body} ret = {"code": code, "body": body.encode("utf-8")}
if headers is not None: if headers is not None:
ret["headers"] = headers ret["headers"] = headers
return ret return ret
Expand Down

0 comments on commit 88268fe

Please sign in to comment.