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

Chalice dont't support bytes when binary_types is application/json #988

Closed
dbritto-dev opened this issue Nov 17, 2018 · 1 comment
Closed

Comments

@dbritto-dev
Copy link
Contributor

The next example doesn't works because when binary_type is application/json chalice encode the body. I created a PR to check if body is a bytes and skip extra conversion to bytes

import json
import gzip
from chalice import Chalice, Response

app = Chalice(app_name='gzipcontent')
app.api.binary_types.append('application/json')

@app.route('/')
def index():
    blob = json.dumps({'hello': 'world'}).encode('utf-8')
    payload = gzip.compress(blob)
    return Response(body=payload, headers={'Content-Type': 'application/json', 'Content-Encoding': 'gzip'})
@dbritto-dev
Copy link
Contributor Author

@jamesls can you review this ?

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

Successfully merging a pull request may close this issue.

1 participant