<!-- Love localstack? Please consider supporting our collective:
👉  https://opencollective.com/localstack/donate -->

# Type of request: This is a ...

[ ] bug report
[x] feature request

# Detailed description

The API Gateway response body only accepts strings. To transfer binary data, it needs to be base64 encoded, inserted as a string in the response body and the flag ´isBase64Encoded´ must be set. Once this is done API Gateway will base64 decode the response and return the binary content to the requester.

## Expected behavior

When setting the isBase64Encoded flag, the response is base64 decoded before being returned from API Gateway.

## Actual behavior

Setting the isBase64Encoded flag has no effect, the response body will contain the base64 encoded string instead of binary data.

# Steps to reproduce

## Command used to start LocalStack

Docker compose config:
```
version: '2.1'

services:
  docker-host:
    image: qoomon/docker-host:2.5.0
    cap_add: [ 'NET_ADMIN', 'NET_RAW' ]
    mem_limit: 20M
    restart: on-failure
  localstack:
    image: localstack/localstack:0.12.10
    depends_on: [ docker-host ]
    ports:
      - "4566:4566"
      - "4571:4571"
    environment:
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
      - DATA_DIR=${TMPDIR}/data
      - DEFAULT_REGION=eu-west-1
      - LAMBDA_REMOTE_DOCKER=0
      - LAMBDA_EXECUTOR=docker-reuse
      - LAMBDA_DOCKER_NETWORK=scripts_default
      - AWS_CBOR_DISABLE=true
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

```

## Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

Need to set up a Lambda Rest API that returns a base64 encoded string, where the flag `isBase64Encoded` is set. The returned response should reflect the base64 decoded version of the string.

import os
import re
import json
import base64
import unittest
import xmltodict
from botocore.exceptions import ClientError
from jsonpatch import apply_patch
from requests.s import Response
from requests.structures import CaseInsensitiveDict
from localstack import config
from localstack.utils import testutil
from localstack.utils.aws import aws_stack
from localstack.constants import TEST_AWS_ACCOUNT_ID, HEADER_LOCALSTACK_REQUEST_URL
from localstack.utils.common import (
    to_str, json_safe, clone, short_uid, get_free_tcp_port,
    load_file, select_attributes, safe_requests as requests)
from localstack.services.infra import start_proxy
from localstack.services.generic_proxy import ProxyListener
from localstack.services.apigateway.helpers import (
    get_rest_api_paths, get_resource_for_path, connect_api_gateway_to_sqs, gateway_request_url)
from localstack.services.awslambda.lambda_api import add_event_source
from localstack.services.awslambda.lambda_utils import LAMBDA_RUNTIME_PYTHON36
from .test_lambda import TEST_LAMBDA_PYTHON, TEST_LAMBDA_LIBS
THIS_FOLDER = os.path.dirname(os.path.realpath(__file__))
TEST_SWAGGER_FILE = os.path.join(THIS_FOLDER, 'files', 'swagger.json')
TEST_IMPORT_REST_API_FILE = os.path.join(THIS_FOLDER, 'files', 'pets.json')