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

# Type of request: This is a ...

[ X ] bug report
[ ] feature request

# Detailed description
Issue originally described and fixed here https://github.com/localstack/localstack/issues/2055 has been reverted by a subsequent change. This PR reverted the fix: https://github.com/localstack/localstack/pull/2202 on file apigateway_listener.py

See original issue for full details.

## Actual behaviour

Serverless Lambda gives a 502 bad gateway response.

`localstack_1  | 2020-04-06T16:03:43:ERROR:localstack.services.generic_proxy: Error forwarding request: 'NoneType' object is not iterable Traceback (most recent call last):
localstack_1  |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 247, in forward
localstack_1  |     listener_result = listener.forward_request(method=method,
localstack_1  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_listener.py", line 47, in forward_request
localstack_1  |     return invoke_rest_api(api_id, stage, method, relative_path_w_query_params, data, headers, path=path)
localstack_1  |   File "/opt/code/localstack/localstack/services/apigateway/apigateway_listener.py", line 254, in invoke_rest_api
localstack_1  |     response.headers.update((parsed_result or {}).get('headers', {}))
localstack_1  |   File "/usr/lib/python3.8/_collections_abc.py", line 837, in update
localstack_1  |     for key, value in other:
localstack_1  | TypeError: 'NoneType' object is not iterable
`
parsed_result = common.json_safe(parsed_result)
            parsed_result = {} if parsed_result is None else parsed_result
            response.status_code = int(parsed_result.get('statusCode', 200))
            response.headers.update((parsed_result or {}).get('headers', {}))
            try:
                if isinstance(parsed_result['body'], dict):
                    response._content = json.dumps(parsed_result['body'])
                else:
                    response._content = to_bytes(parsed_result['body'])
            except Exception:
                response._content = '{}'
            response.headers['Content-Length'] = len(response._content)
            return response
        else:
            msg = 'API Gateway action uri "%s" not yet implemented' % uri
            LOGGER.warning(msg)
            return make_error_response(msg, 404)
    elif integration['type'] == 'HTTP':
        function = getattr(requests, method.lower())
        if isinstance(data, dict):
            data = json.dumps(data)
        result = function(integration['uri'], data=data, headers=headers)
        return result
    else:
        msg = ('API Gateway integration type "%s" for method "%s" not yet implemented' %
               (integration['type'], method))
        LOGGER.warning(msg)
        return make_error_response(msg, 404)
UPDATE_APIGATEWAY = ProxyListenerApiGateway()