Skip to content

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

@dbritto-dev

Description

@dbritto-dev

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'})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions