Skip to content

Support binary payloads and responses, and non-UTF8 string payloads for Python functions #205

Open
@jpauwels

Description

@jpauwels

The Python templates currently don't support binary payloads and responses, whereas other templates do (e.g. image-handling functions in store). Much like #203 and #159 for Java, it would be nice to add this capability to the Python templates. Additionally, string payloads are assumed to be UTF-8 encoded, even if content-type signals differently.

Expected Behaviour

When passing binary payload, don't decode to string. When passing string payload, respect content-type encoding.
When returning binary file, don't encode as string.

Current Behaviour

UnicodeDecodeError when passing binary payload, incorrect decoding when passing non-UTF-8 string payload. Binary responses get stringified.

Possible Solution

I've got this fixed and working for more than a year in my custom template, happy to send a PR

Steps to Reproduce (for bugs)

Context

Using audio files as payload

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
    All
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?
    Swarm
  • Operating System and version (e.g. Linux, Windows, MacOS):
    Linux, MacOS
  • Link to your project or a code example to reproduce issue:

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