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

Passing a unicode type body to Response causes body to be json encoded #262

Closed
gene1wood opened this issue Mar 27, 2017 · 1 comment · Fixed by #395
Closed

Passing a unicode type body to Response causes body to be json encoded #262

gene1wood opened this issue Mar 27, 2017 · 1 comment · Fixed by #395
Labels

Comments

@gene1wood
Copy link
Contributor

https://github.com/awslabs/chalice/blob/a8d68083e8e76f096307cdd992686b658e39f1a2/chalice/app.py#L144-L145

If you pass a unicode typed body variable to the Response object it json encodes the value.

Steps to reproduce

from chalice import Chalice, Response

app = Chalice(app_name='example')

@app.route('/')
def index():
    body = u'<h1>test</h1>'
    return Response(body=body,
                    status_code=200,
                    headers={'Content-Type': 'text/html'})

Expected results

<h1>test</h1>

Actual results

"<h1>test</h1>"

Suggested change

It would make sense to check for str or unicode strings here

@stealthycoin
Copy link
Contributor

Looks like this is still an issue. Although its worth noting that it is only an issue on python 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants