Skip to content

Commit

Permalink
Fix 500 error on overly-large API request body
Browse files Browse the repository at this point in the history
Paster doesn't mind unicode responses, but gunicorn wants byte strings
only:

    Error handling request
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 131, in handle_request
        resp.write(item)
      File "/usr/lib/python2.7/dist-packages/gunicorn/http/wsgi.py", line 283, in write
        assert isinstance(arg, binary_type), "%r is not a byte." % arg
    AssertionError: u'{' is not a byte.

See https://gist.github.com/JordanMilne/4a7d1b5eb317e607479b for repro
  • Loading branch information
JordanMilne committed Jun 24, 2015
1 parent 35fa814 commit ec607e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion r2/r2/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _wsgi_json(start_response, status_int, message=""):
"error": status_int,
"message": message
})
return filters.websafe_json(data)
return [filters.websafe_json(data).encode("utf-8")]


class LimitUploadSize(object):
Expand Down

0 comments on commit ec607e7

Please sign in to comment.