<!-- 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
`
import re
import json
import logging
import requests
from flask import Response as FlaskResponse
from six.moves.urllib_parse import urljoin
from requests.models import Response
from localstack.constants import APPLICATION_JSON, PATH_USER_REQUEST
from localstack.config import TEST_KINESIS_URL, TEST_SQS_URL
from localstack.utils import common
from localstack.utils.aws import aws_stack
from localstack.utils.common import to_str, to_bytes
from localstack.utils.analytics import event_publisher
from localstack.services.kinesis import kinesis_listener
from localstack.services.awslambda import lambda_api
from localstack.services.apigateway import helpers
from localstack.services.generic_proxy import ProxyListener
from localstack.utils.aws.aws_responses import flask_to_requests_response, requests_response
from localstack.services.apigateway.helpers import (get_resource_for_path,
    handle_authorizers, extract_query_string_params,
    extract_path_params, make_error_response, get_cors_response)
LOGGER = logging.getLogger(__name__)
PATH_REGEX_AUTHORIZERS = r'^/restapis/([A-Za-z0-9_\-]+)/authorizers(\?.*)?'
PATH_REGEX_RESPONSES = r'^/restapis/([A-Za-z0-9_\-]+)/gatewayresponses(/[A-Za-z0-9_\-]+)?(\?.*)?'
PATH_REGEX_USER_REQUEST = r'^/restapis/([A-Za-z0-9_\-]+)/([A-Za-z0-9_\-]+)/%s/(.*)$' % PATH_USER_REQUEST
GATEWAY_RESPONSES = {}
class AuthorizationError(Exception):