### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Hi, I'm testing the image `localstack/localstack:0.14.5`, and setting `LEGACY_EDGE_PROXY=1` makes the following cleanup code much slower:

`for queue in client.list_queues()['QueueUrls']: client.purge_queue(QueueUrl=queue)`

`LEGACY_EDGE_PROXY=1`: `56.2 ms ± 2.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)`

`LEGACY_EDGE_PROXY=0`: `258 ms ± 17.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)`


### Expected Behavior

I expected performance to improve or not to regress.

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

# Benchmark setup:

Docker-compose file:
```
version: "3.9"
services:
  localstack:
    image: localstack/localstack:latest
    environment:
      - DEFAULT_REGION=eu-west-1
      - SERVICES=s3,sns,sqs
      - LEGACY_EDGE_PROXY=1  # or 0
    ipc: host
```

```
# docker-compose rm -f localstack && docker-compose up localstack
```

```
import boto3

client = boto3.resource(
    'sqs',
    endpoint_url="http://localstack:4566/",
    region_name='eu-west-1',
    aws_secret_access_key="x",
    aws_access_key_id="x",
    use_ssl=False,
).meta.client

for i in range(10):
    client.create_queue(QueueName=str(i))

queues = client.list_queues()['QueueUrls']
assert len(queues) == 10
```

```
In [3]: %timeit for queue in client.list_queues()['QueueUrls']: client.purge_queue(QueueUrl=queue)
```

### Environment

```markdown
- OS: Ubuntu 22.04 LTS, Linux 5.15.0-40-generic #43-Ubuntu SMP Wed Jun 15 12:54:21 UTC 2022 x86_64 
- docker-compose 1.29.2
- Docker: 20.10.12, build 20.10.12-0ubuntu4
- LocalStack: 0.14.5
```


### Anything else?

Results don't improve over time, it's not a cold start issue.

https://github.com/localstack/localstack/issues/6398
""" Handlers for compatibility with legacy edge proxy and the quart http framework."""
import logging
import re
from typing import Mapping
from requests import Response as RequestsResponse
from localstack.constants import HEADER_LOCALSTACK_EDGE_URL, HEADER_LOCALSTACK_REQUEST_URL
from localstack.http import Response
from localstack.http.request import restore_payload
from localstack.services.generic_proxy import ProxyListener, modify_and_forward
from ..api import RequestContext
from ..chain import Handler, HandlerChain
from .routes import RouterHandler
LOG = logging.getLogger(__name__)
def push_request_context(_chain: HandlerChain, context: RequestContext, _response: Response):
    
    
    
    
    import flask.globals
    import quart.globals
    from localstack.utils.aws import request_context
    quart.globals._request_ctx_stack.push(context)
    flask.globals._request_ctx_stack.push(context)
    request_context.THREAD_LOCAL.request_context = context.request
def pop_request_context(_chain: HandlerChain, _context: RequestContext, _response: Response):