Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(encoding): Fix double-encoding of HTTP response #220

Merged
merged 1 commit into from
Oct 7, 2019
Merged

fix(encoding): Fix double-encoding of HTTP response #220

merged 1 commit into from
Oct 7, 2019

Commits on Oct 4, 2019

  1. fix(encoding): Fix double-encoding of HTTP response

    ecba3ea added a call to encode
    the response body before sending it to the server if the body is
    of type str.
    
    This is the correct behavior for python 3, where str represents a
    an unencoded string, but is incorrect for python 2. In python 2,
    str represents an already-encoded string and unicode represents
    an unencoded string.
    
    This is breaking for prometheus monitoring, which is sending already-
    encoded bytes to the respond() function. In python 2, those have type
    str, so we're trying to re-encode them. This works fine as long as there
    are only ASCII characters in the string, but breaks otherwise.
    
    In order to support both python 2 and 3, try to use 'unicode' (as
    exists in 2) and if it's absent assign str to unicode.
    ezimanyi committed Oct 4, 2019
    Configuration menu
    Copy the full SHA
    a9203b6 View commit details
    Browse the repository at this point in the history